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/power_monitor/power_monitor.h"
12 #include "base/power_monitor/power_monitor_device_source.h"
13 #include "base/run_loop.h"
14 #include "ui/base/ime/input_method_initializer.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/ui_base_paths.h"
17 #include "ui/compositor/test/in_process_context_factory.h"
18 #include "ui/gfx/screen.h"
19 #include "ui/gl/gl_surface.h"
20 #include "ui/views/examples/example_base.h"
21 #include "ui/views/examples/examples_window.h"
22 #include "ui/views/test/desktop_test_views_delegate.h"
25 #include "ui/aura/env.h"
26 #include "ui/wm/core/wm_state.h"
29 #if !defined(OS_CHROMEOS) && defined(USE_AURA)
30 #include "ui/views/widget/desktop_aura/desktop_screen.h"
34 #include "ui/base/win/scoped_ole_initializer.h"
35 #include "ui/gfx/win/direct_write.h"
39 #include "ui/gfx/x/x11_connection.h"
42 int main(int argc
, char** argv
) {
44 ui::ScopedOleInitializer ole_initializer_
;
47 base::CommandLine::Init(argc
, argv
);
49 base::AtExitManager at_exit
;
52 // This demo uses InProcessContextFactory which uses X on a separate Gpu
54 gfx::InitializeThreadedX11();
57 gfx::GLSurface::InitializeOneOff();
59 // The ContextFactory must exist before any Compositors are created.
60 bool context_factory_for_test
= false;
61 scoped_ptr
<ui::InProcessContextFactory
> context_factory(
62 new ui::InProcessContextFactory(context_factory_for_test
, nullptr));
63 context_factory
->set_use_test_surface(false);
65 base::MessageLoopForUI message_loop
;
67 base::i18n::InitializeICU();
69 ui::RegisterPathProvider();
71 base::FilePath ui_test_pak_path
;
72 CHECK(PathService::Get(ui::UI_TEST_PAK
, &ui_test_pak_path
));
73 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path
);
75 base::PowerMonitor
power_monitor(make_scoped_ptr(
76 new base::PowerMonitorDeviceSource
));
79 gfx::win::MaybeInitializeDirectWrite();
83 aura::Env::CreateInstance(true);
84 aura::Env::GetInstance()->set_context_factory(context_factory
.get());
86 ui::InitializeInputMethodForTesting();
89 views::DesktopTestViewsDelegate views_delegate
;
93 #if !defined(OS_CHROMEOS) && defined(USE_AURA)
94 scoped_ptr
<gfx::Screen
> desktop_screen(views::CreateDesktopScreen());
95 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE
,
96 desktop_screen
.get());
99 views::examples::ShowExamplesWindow(
100 views::examples::QUIT_ON_CLOSE
,
102 scoped_ptr
<ScopedVector
<views::examples::ExampleBase
> >());
104 base::RunLoop().Run();
106 ui::ResourceBundle::CleanupSharedInstance();
109 ui::ShutdownInputMethod();
111 #if defined(USE_AURA)
112 aura::Env::DeleteInstance();