1 // Copyright 2012 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.
5 #include "base/at_exit.h"
6 #include "base/command_line.h"
7 #include "base/files/file_path.h"
8 #include "base/i18n/icu_util.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h"
11 #include "base/run_loop.h"
12 #include "ui/aura/env.h"
13 #include "ui/base/ime/input_method_initializer.h"
14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/test/context_factories_for_test.h"
16 #include "ui/gfx/screen.h"
17 #include "ui/gl/gl_surface.h"
18 #include "ui/views/corewm/wm_state.h"
19 #include "ui/views/examples/example_base.h"
20 #include "ui/views/examples/examples_window.h"
21 #include "ui/views/test/desktop_test_views_delegate.h"
23 #if !defined(OS_CHROMEOS)
24 #include "ui/views/widget/desktop_aura/desktop_screen.h"
27 #include "ui/base/win/scoped_ole_initializer.h"
30 int main(int argc, char** argv) {
32 ui::ScopedOleInitializer ole_initializer_;
35 CommandLine::Init(argc, argv);
37 base::AtExitManager at_exit;
38 base::MessageLoopForUI message_loop;
40 base::i18n::InitializeICU();
42 base::FilePath pak_dir;
43 PathService::Get(base::DIR_MODULE, &pak_dir);
45 base::FilePath pak_file;
46 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak"));
48 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
50 gfx::GLSurface::InitializeOneOff();
52 // The ContextFactory must exist before any Compositors are created.
53 bool allow_test_contexts = false;
54 ui::InitializeContextFactoryForTests(allow_test_contexts);
56 aura::Env::CreateInstance();
58 ui::InitializeInputMethodForTesting();
61 views::DesktopTestViewsDelegate views_delegate;
62 views::corewm::WMState wm_state;
64 #if !defined(OS_CHROMEOS)
65 scoped_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen());
66 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
67 desktop_screen.get());
70 views::examples::ShowExamplesWindow(
71 views::examples::QUIT_ON_CLOSE,
73 scoped_ptr<ScopedVector<views::examples::ExampleBase> >());
75 base::RunLoop().Run();
77 ui::ResourceBundle::CleanupSharedInstance();
80 ui::ShutdownInputMethod();
82 aura::Env::DeleteInstance();