Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: ui/aura/test/aura_test_helper.cc

Issue 2807833002: [views-mus] Prevent creating a native OzonePlatform in mus tests. (Closed)
Patch Set: sky comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/test/aura_test_helper.cc
diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc
index 25ffb484f1c7026df7258607e8c39d6ca42aa2f2..8b832269e55d62c8073d7a36f212c0913a37a277 100644
--- a/ui/aura/test/aura_test_helper.cc
+++ b/ui/aura/test/aura_test_helper.cc
@@ -4,6 +4,7 @@
#include "ui/aura/test/aura_test_helper.h"
+#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -122,24 +123,25 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory,
ui::InitializeInputMethodForTesting();
- display::Screen* screen = display::Screen::GetScreen();
- gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel()
- : gfx::Size(800, 600));
- // TODO(sky): creating the screen and host should not happen for mus.
- test_screen_.reset(TestScreen::Create(host_size));
- if (!screen)
- display::Screen::SetScreenInstance(test_screen_.get());
- host_.reset(test_screen_->CreateHostForPrimaryDisplay());
- host_->window()->SetEventTargeter(
- std::unique_ptr<ui::EventTargeter>(new WindowTargeter()));
-
- client::SetFocusClient(root_window(), focus_client_.get());
- client::SetCaptureClient(root_window(), capture_client());
- parenting_client_.reset(new TestWindowParentingClient(root_window()));
-
- root_window()->Show();
- // Ensure width != height so tests won't confuse them.
- host()->SetBoundsInPixels(gfx::Rect(host_size));
+ if (mode_ != Mode::MUS) {
+ display::Screen* screen = display::Screen::GetScreen();
+ gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel()
+ : gfx::Size(800, 600));
+ test_screen_.reset(TestScreen::Create(host_size));
+ if (!screen)
+ display::Screen::SetScreenInstance(test_screen_.get());
+ host_.reset(test_screen_->CreateHostForPrimaryDisplay());
+ host_->window()->SetEventTargeter(
+ std::unique_ptr<ui::EventTargeter>(new WindowTargeter()));
+
+ client::SetFocusClient(root_window(), focus_client_.get());
+ client::SetCaptureClient(root_window(), capture_client());
+ parenting_client_.reset(new TestWindowParentingClient(root_window()));
+
+ root_window()->Show();
+ // Ensure width != height so tests won't confuse them.
+ host()->SetBoundsInPixels(gfx::Rect(host_size));
+ }
if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) {
window_tree_client_->focus_synchronizer()->SetActiveFocusClient(
@@ -154,18 +156,20 @@ void AuraTestHelper::TearDown() {
g_instance = nullptr;
teardown_called_ = true;
parenting_client_.reset();
- client::SetFocusClient(root_window(), nullptr);
- client::SetCaptureClient(root_window(), nullptr);
- host_.reset();
- ui::GestureRecognizer::Reset();
- if (display::Screen::GetScreen() == test_screen_.get())
- display::Screen::SetScreenInstance(nullptr);
- test_screen_.reset();
+ if (mode_ != Mode::MUS) {
+ client::SetFocusClient(root_window(), nullptr);
+ client::SetCaptureClient(root_window(), nullptr);
+ host_.reset();
- window_tree_client_setup_.reset();
- focus_client_.reset();
- capture_client_.reset();
+ if (display::Screen::GetScreen() == test_screen_.get())
+ display::Screen::SetScreenInstance(nullptr);
+ test_screen_.reset();
+ window_tree_client_setup_.reset();
+ focus_client_.reset();
+ capture_client_.reset();
+ }
+ ui::GestureRecognizer::Reset();
ui::ShutdownInputMethodForTesting();
if (env_)

Powered by Google App Engine
This is Rietveld 408576698