Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / athena / main / athena_shell.cc
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/activity/public/activity_factory.h"
6 #include "athena/activity/public/activity_manager.h"
7 #include "athena/test/athena_test_helper.h"
8 #include "base/at_exit.h"
9 #include "base/base_paths.h"
10 #include "base/command_line.h"
11 #include "base/i18n/icu_util.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h"
14 #include "base/run_loop.h"
15 #include "ui/aura/window_tree_host.h"
16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/compositor/test/context_factories_for_test.h"
18 #include "ui/gl/gl_surface.h"
19
20 class UIShell {
21  public:
22   explicit UIShell(base::MessageLoopForUI* message_loop)
23       : athena_helper_(message_loop) {
24     const bool enable_pixel_output = true;
25     ui::ContextFactory* factory =
26         ui::InitializeContextFactoryForTests(enable_pixel_output);
27     athena_helper_.SetUp(factory);
28     athena_helper_.host()->Show();
29
30     InitSampleActivities();
31   }
32
33   void InitSampleActivities() {
34     athena::ActivityManager::Get()->AddActivity(
35         athena::ActivityFactory::Get()->CreateWebActivity(
36             NULL, GURL("http://www.google.com/")));
37   }
38
39  private:
40   athena::test::AthenaTestHelper athena_helper_;
41
42   DISALLOW_COPY_AND_ASSIGN(UIShell);
43 };
44
45 int main(int argc, const char **argv) {
46   setlocale(LC_ALL, "");
47
48   base::AtExitManager exit_manager;
49   base::CommandLine::Init(argc, argv);
50   base::i18n::InitializeICU();
51   gfx::GLSurface::InitializeOneOffForTests();
52
53   base::FilePath test_pak_path;
54   CHECK(PathService::Get(base::DIR_MODULE, &test_pak_path));
55   test_pak_path = test_pak_path.AppendASCII("athena_resources.pak");
56   ui::ResourceBundle::InitSharedInstanceWithPakPath(test_pak_path);
57
58   base::MessageLoopForUI message_loop;
59   UIShell shell(&message_loop);
60   base::RunLoop run_loop;
61   run_loop.Run();
62 }