Chromium Code Reviews| 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/default_capture_client.h" | 9 #include "ui/aura/client/default_capture_client.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() | 71 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() |
| 72 : gfx::Size(800, 600)); | 72 : gfx::Size(800, 600)); |
| 73 test_screen_.reset(TestScreen::Create(host_size)); | 73 test_screen_.reset(TestScreen::Create(host_size)); |
| 74 if (!screen) | 74 if (!screen) |
| 75 display::Screen::SetScreenInstance(test_screen_.get()); | 75 display::Screen::SetScreenInstance(test_screen_.get()); |
| 76 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); | 76 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); |
| 77 | 77 |
| 78 focus_client_.reset(new TestFocusClient); | 78 focus_client_.reset(new TestFocusClient); |
| 79 client::SetFocusClient(root_window(), focus_client_.get()); | 79 client::SetFocusClient(root_window(), focus_client_.get()); |
| 80 parenting_client_.reset(new TestWindowParentingClient(root_window())); | 80 parenting_client_.reset(new TestWindowParentingClient(root_window())); |
| 81 capture_client_.reset(new client::DefaultCaptureClient(root_window())); | 81 capture_client_ = base::MakeUnique<client::DefaultCaptureClient>(); |
| 82 SetCaptureClient(host_->window(), capture_client_.get()); | |
|
msw
2016/10/25 19:21:08
nit: client:: needed here like below?
msw
2016/10/25 19:21:08
aside: odd that host_->window()'s root is not root
sky
2016/10/25 19:44:40
Surprisingly it isn't needed here, but is needed b
msw
2016/10/25 19:47:59
Odd... I might add it to be clear/consistent, but
| |
| 82 | 83 |
| 83 root_window()->Show(); | 84 root_window()->Show(); |
| 84 // Ensure width != height so tests won't confuse them. | 85 // Ensure width != height so tests won't confuse them. |
| 85 host()->SetBounds(gfx::Rect(host_size)); | 86 host()->SetBounds(gfx::Rect(host_size)); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void AuraTestHelper::TearDown() { | 89 void AuraTestHelper::TearDown() { |
| 89 teardown_called_ = true; | 90 teardown_called_ = true; |
| 90 parenting_client_.reset(); | 91 parenting_client_.reset(); |
| 92 client::SetCaptureClient(host_->window(), nullptr); | |
| 91 capture_client_.reset(); | 93 capture_client_.reset(); |
| 92 focus_client_.reset(); | 94 focus_client_.reset(); |
| 93 client::SetFocusClient(root_window(), nullptr); | 95 client::SetFocusClient(root_window(), nullptr); |
| 94 host_.reset(); | 96 host_.reset(); |
| 95 ui::GestureRecognizer::Reset(); | 97 ui::GestureRecognizer::Reset(); |
| 96 if (display::Screen::GetScreen() == test_screen_.get()) | 98 if (display::Screen::GetScreen() == test_screen_.get()) |
| 97 display::Screen::SetScreenInstance(nullptr); | 99 display::Screen::SetScreenInstance(nullptr); |
| 98 test_screen_.reset(); | 100 test_screen_.reset(); |
| 99 | 101 |
| 100 #if defined(USE_X11) | 102 #if defined(USE_X11) |
| 101 ui::test::ResetXCursorCache(); | 103 ui::test::ResetXCursorCache(); |
| 102 #endif | 104 #endif |
| 103 | 105 |
| 104 ui::ShutdownInputMethodForTesting(); | 106 ui::ShutdownInputMethodForTesting(); |
| 105 | 107 |
| 106 env_.reset(); | 108 env_.reset(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void AuraTestHelper::RunAllPendingInMessageLoop() { | 111 void AuraTestHelper::RunAllPendingInMessageLoop() { |
| 110 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 112 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 111 // use run_loop.QuitClosure(). | 113 // use run_loop.QuitClosure(). |
| 112 base::RunLoop run_loop; | 114 base::RunLoop run_loop; |
| 113 run_loop.RunUntilIdle(); | 115 run_loop.RunUntilIdle(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 } // namespace test | 118 } // namespace test |
| 117 } // namespace aura | 119 } // namespace aura |
| OLD | NEW |