OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/test/aura_test_helper.h" | 5 #include "ui/aura/test/aura_test_helper.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #endif | 45 #endif |
46 } | 46 } |
47 | 47 |
48 AuraTestHelper::~AuraTestHelper() { | 48 AuraTestHelper::~AuraTestHelper() { |
49 CHECK(setup_called_) | 49 CHECK(setup_called_) |
50 << "AuraTestHelper::SetUp() never called."; | 50 << "AuraTestHelper::SetUp() never called."; |
51 CHECK(teardown_called_) | 51 CHECK(teardown_called_) |
52 << "AuraTestHelper::TearDown() never called."; | 52 << "AuraTestHelper::TearDown() never called."; |
53 } | 53 } |
54 | 54 |
55 void AuraTestHelper::SetUp() { | 55 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { |
56 setup_called_ = true; | 56 setup_called_ = true; |
57 | 57 |
58 Env::CreateInstance(true); | 58 Env::CreateInstance(true); |
59 // Unit tests generally don't want to query the system, rather use the state | 59 // Unit tests generally don't want to query the system, rather use the state |
60 // from RootWindow. | 60 // from RootWindow. |
61 EnvTestHelper(Env::GetInstance()).SetInputStateLookup( | 61 EnvTestHelper(Env::GetInstance()).SetInputStateLookup( |
62 scoped_ptr<InputStateLookup>()); | 62 scoped_ptr<InputStateLookup>()); |
63 | 63 |
64 ui::InitializeInputMethodForTesting(); | 64 ui::InitializeInputMethodForTesting(); |
65 | 65 |
66 test_screen_.reset(TestScreen::Create()); | 66 test_screen_.reset(TestScreen::Create()); |
67 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 67 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
68 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); | 68 host_.reset(test_screen_->CreateHostForPrimaryDisplay(context_factory)); |
69 | 69 |
70 focus_client_.reset(new TestFocusClient); | 70 focus_client_.reset(new TestFocusClient); |
71 client::SetFocusClient(root_window(), focus_client_.get()); | 71 client::SetFocusClient(root_window(), focus_client_.get()); |
72 stacking_client_.reset(new TestWindowTreeClient(root_window())); | 72 stacking_client_.reset(new TestWindowTreeClient(root_window())); |
73 capture_client_.reset(new client::DefaultCaptureClient(root_window())); | 73 capture_client_.reset(new client::DefaultCaptureClient(root_window())); |
74 test_input_method_.reset(new ui::DummyInputMethod); | 74 test_input_method_.reset(new ui::DummyInputMethod); |
75 root_window()->SetProperty( | 75 root_window()->SetProperty( |
76 client::kRootWindowInputMethodKey, | 76 client::kRootWindowInputMethodKey, |
77 test_input_method_.get()); | 77 test_input_method_.get()); |
78 | 78 |
(...skipping 25 matching lines...) Expand all Loading... |
104 | 104 |
105 void AuraTestHelper::RunAllPendingInMessageLoop() { | 105 void AuraTestHelper::RunAllPendingInMessageLoop() { |
106 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 106 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
107 // use run_loop.QuitClosure(). | 107 // use run_loop.QuitClosure(). |
108 base::RunLoop run_loop; | 108 base::RunLoop run_loop; |
109 run_loop.RunUntilIdle(); | 109 run_loop.RunUntilIdle(); |
110 } | 110 } |
111 | 111 |
112 } // namespace test | 112 } // namespace test |
113 } // namespace aura | 113 } // namespace aura |
OLD | NEW |