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/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"
23 #include "ui/aura/env.h"
24 #include "ui/wm/core/wm_state.h"
27 #if !defined(OS_CHROMEOS) && defined(USE_AURA)
28 #include "ui/views/widget/desktop_aura/desktop_screen.h"
32 #include "ui/base/win/scoped_ole_initializer.h"
36 #include "ui/gfx/x/x11_connection.h"
39 int main(int argc
, char** argv
) {
41 ui::ScopedOleInitializer ole_initializer_
;
44 CommandLine::Init(argc
, argv
);
46 base::AtExitManager at_exit
;
49 // This demo uses InProcessContextFactory which uses X on a separate Gpu
51 gfx::InitializeThreadedX11();
54 gfx::GLSurface::InitializeOneOff();
56 // The ContextFactory must exist before any Compositors are created.
57 scoped_ptr
<ui::InProcessContextFactory
> context_factory(
58 new ui::InProcessContextFactory());
60 base::MessageLoopForUI message_loop
;
62 base::i18n::InitializeICU();
64 ui::RegisterPathProvider();
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
);
71 aura::Env::CreateInstance(true);
72 aura::Env::GetInstance()->set_context_factory(context_factory
.get());
74 ui::InitializeInputMethodForTesting();
77 views::DesktopTestViewsDelegate views_delegate
;
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());
87 views::examples::ShowExamplesWindow(
88 views::examples::QUIT_ON_CLOSE
,
90 scoped_ptr
<ScopedVector
<views::examples::ExampleBase
> >());
92 base::RunLoop().Run();
94 ui::ResourceBundle::CleanupSharedInstance();
97 ui::ShutdownInputMethod();
100 aura::Env::DeleteInstance();