OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "athena/test/athena_test_helper.h" | 5 #include "athena/test/athena_test_helper.h" |
6 | 6 |
7 #include "athena/main/athena_launcher.h" | 7 #include "athena/main/athena_launcher.h" |
8 #include "athena/screen/public/screen_manager.h" | 8 #include "athena/screen/public/screen_manager.h" |
9 #include "athena/test/sample_activity_factory.h" | 9 #include "athena/test/sample_activity_factory.h" |
10 #include "athena/test/test_app_model_builder.h" | 10 #include "athena/test/test_app_model_builder.h" |
11 #include "athena/test/test_screen_manager_delegate.h" | 11 #include "athena/test/test_screen_manager_delegate.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/threading/thread.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "ui/app_list/app_list_switches.h" | 17 #include "ui/app_list/app_list_switches.h" |
17 #include "ui/aura/client/aura_constants.h" | 18 #include "ui/aura/client/aura_constants.h" |
18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
19 #include "ui/aura/input_state_lookup.h" | 20 #include "ui/aura/input_state_lookup.h" |
20 #include "ui/aura/test/env_test_helper.h" | 21 #include "ui/aura/test/env_test_helper.h" |
21 #include "ui/aura/test/test_focus_client.h" | 22 #include "ui/aura/test/test_focus_client.h" |
22 #include "ui/aura/test/test_screen.h" | 23 #include "ui/aura/test/test_screen.h" |
23 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
24 #include "ui/base/ime/input_method_initializer.h" | 25 #include "ui/base/ime/input_method_initializer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
43 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 44 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
44 } | 45 } |
45 | 46 |
46 AthenaTestHelper::~AthenaTestHelper() { | 47 AthenaTestHelper::~AthenaTestHelper() { |
47 CHECK(setup_called_) << "AthenaTestHelper::SetUp() never called."; | 48 CHECK(setup_called_) << "AthenaTestHelper::SetUp() never called."; |
48 CHECK(teardown_called_) << "AthenaTestHelper::TearDown() never called."; | 49 CHECK(teardown_called_) << "AthenaTestHelper::TearDown() never called."; |
49 } | 50 } |
50 | 51 |
51 void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { | 52 void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { |
52 setup_called_ = true; | 53 setup_called_ = true; |
| 54 file_thread_.reset(new base::Thread("FileThread")); |
| 55 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
| 56 file_thread_->StartWithOptions(options); |
53 | 57 |
54 // Force showing in the experimental app-list view. | 58 // Force showing in the experimental app-list view. |
55 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 59 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
56 app_list::switches::kEnableExperimentalAppList); | 60 app_list::switches::kEnableExperimentalAppList); |
57 | 61 |
58 chromeos::DBusThreadManager::InitializeWithStub(); | 62 chromeos::DBusThreadManager::InitializeWithStub(); |
59 | 63 |
60 aura::Env::CreateInstance(true); | 64 aura::Env::CreateInstance(true); |
61 aura::Env::GetInstance()->set_context_factory(context_factory); | 65 aura::Env::GetInstance()->set_context_factory(context_factory); |
62 | 66 |
(...skipping 20 matching lines...) Expand all Loading... |
83 new wm::FocusController(ScreenManager::CreateFocusRules()); | 87 new wm::FocusController(ScreenManager::CreateFocusRules()); |
84 aura::client::SetFocusClient(root_window(), focus_controller); | 88 aura::client::SetFocusClient(root_window(), focus_controller); |
85 root_window()->AddPreTargetHandler(focus_controller); | 89 root_window()->AddPreTargetHandler(focus_controller); |
86 aura::client::SetActivationClient(root_window(), focus_controller); | 90 aura::client::SetActivationClient(root_window(), focus_controller); |
87 focus_client_.reset(focus_controller); | 91 focus_client_.reset(focus_controller); |
88 | 92 |
89 root_window()->Show(); | 93 root_window()->Show(); |
90 // Ensure width != height so tests won't confuse them. | 94 // Ensure width != height so tests won't confuse them. |
91 host()->SetBounds(gfx::Rect(host_size)); | 95 host()->SetBounds(gfx::Rect(host_size)); |
92 | 96 |
93 athena::StartAthenaEnv(root_window(), screen_manager_delegate_.get()); | 97 athena::StartAthenaEnv(root_window(), screen_manager_delegate_.get(), |
| 98 file_thread_->message_loop_proxy()); |
94 athena::StartAthenaSession(new SampleActivityFactory(), | 99 athena::StartAthenaSession(new SampleActivityFactory(), |
95 new TestAppModelBuilder()); | 100 new TestAppModelBuilder()); |
96 } | 101 } |
97 | 102 |
98 void AthenaTestHelper::TearDown() { | 103 void AthenaTestHelper::TearDown() { |
99 teardown_called_ = true; | 104 teardown_called_ = true; |
100 | 105 |
101 athena::ShutdownAthena(); | 106 athena::ShutdownAthena(); |
102 | 107 |
103 aura::client::SetFocusClient(root_window(), NULL); | 108 aura::client::SetFocusClient(root_window(), NULL); |
(...skipping 18 matching lines...) Expand all Loading... |
122 | 127 |
123 void AthenaTestHelper::RunAllPendingInMessageLoop() { | 128 void AthenaTestHelper::RunAllPendingInMessageLoop() { |
124 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 129 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
125 // use run_loop.QuitClosure(). | 130 // use run_loop.QuitClosure(). |
126 base::RunLoop run_loop; | 131 base::RunLoop run_loop; |
127 run_loop.RunUntilIdle(); | 132 run_loop.RunUntilIdle(); |
128 } | 133 } |
129 | 134 |
130 } // namespace test | 135 } // namespace test |
131 } // namespace athena | 136 } // namespace athena |
OLD | NEW |