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. 4 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/base/ime/input_method_initializer.h" 13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/ui_base_paths.h" 15 #include "ui/compositor/test/in_process_context_factory.h" 16 #include "ui/gfx/screen.h" 17 #include "ui/gl/gl_surface.h" 18 #include "ui/views/examples/example_base.h" 19 #include "ui/views/examples/examples_window.h" 20 #include "ui/views/test/desktop_test_views_delegate.h" 21 22 #if defined(USE_AURA) 23 #include "ui/aura/env.h" 24 #include "ui/wm/core/wm_state.h" 25 #endif 26 27 #if !defined(OS_CHROMEOS) && defined(USE_AURA) 28 #include "ui/views/widget/desktop_aura/desktop_screen.h" 29 #endif 30 31 #if defined(OS_WIN) 32 #include "ui/base/win/scoped_ole_initializer.h" 33 #endif 34 35 #if defined(USE_X11) 36 #include "ui/gfx/x/x11_connection.h" 37 #endif 38 main(int argc,char ** argv)39int main(int argc, char** argv) { 40 #if defined(OS_WIN) 41 ui::ScopedOleInitializer ole_initializer_; 42 #endif 43 44 CommandLine::Init(argc, argv); 45 46 base::AtExitManager at_exit; 47 48 #if defined(USE_X11) 49 // This demo uses InProcessContextFactory which uses X on a separate Gpu 50 // thread. 51 gfx::InitializeThreadedX11(); 52 #endif 53 54 gfx::GLSurface::InitializeOneOff(); 55 56 // The ContextFactory must exist before any Compositors are created. 57 scoped_ptr<ui::InProcessContextFactory> context_factory( 58 new ui::InProcessContextFactory()); 59 60 base::MessageLoopForUI message_loop; 61 62 base::i18n::InitializeICU(); 63 64 ui::RegisterPathProvider(); 65 66 base::FilePath ui_test_pak_path; 67 DCHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 68 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 69 70 #if defined(USE_AURA) 71 aura::Env::CreateInstance(true); 72 aura::Env::GetInstance()->set_context_factory(context_factory.get()); 73 #endif 74 ui::InitializeInputMethodForTesting(); 75 76 { 77 views::DesktopTestViewsDelegate views_delegate; 78 #if defined(USE_AURA) 79 wm::WMState wm_state; 80 #endif 81 #if !defined(OS_CHROMEOS) && defined(USE_AURA) 82 scoped_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen()); 83 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, 84 desktop_screen.get()); 85 #endif 86 87 views::examples::ShowExamplesWindow( 88 views::examples::QUIT_ON_CLOSE, 89 NULL, 90 scoped_ptr<ScopedVector<views::examples::ExampleBase> >()); 91 92 base::RunLoop().Run(); 93 94 ui::ResourceBundle::CleanupSharedInstance(); 95 } 96 97 ui::ShutdownInputMethod(); 98 99 #if defined(USE_AURA) 100 aura::Env::DeleteInstance(); 101 #endif 102 103 return 0; 104 } 105