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

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

Issue 2807833002: [views-mus] Prevent creating a native OzonePlatform in mus tests. (Closed)
Patch Set: Use the same detection method at all levels. 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
« no previous file with comments | « no previous file | ui/views/BUILD.gn » ('j') | ui/views/BUILD.gn » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4d422477ba1ba31e396825d304f7aaeff9f7ccc6 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"
@@ -45,6 +46,12 @@ namespace {
AuraTestHelper* g_instance = nullptr;
+// Returns true if running inside of mus. Checks for mojo specific flag.
+bool RunningInsideMus() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ "primordial-pipe-token");
sky 2017/04/10 23:53:26 Use kPrimordialPipeToken?
Elliot Glaysher 2017/04/12 18:09:16 Removed.
+}
+
} // namespace
AuraTestHelper::AuraTestHelper(base::MessageLoopForUI* message_loop)
@@ -122,24 +129,26 @@ 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 (!RunningInsideMus()) {
+ 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.
sky 2017/04/10 23:53:26 You can remove this todo now.
Elliot Glaysher 2017/04/12 18:09:16 Done.
+ 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 +163,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();
+ if (!RunningInsideMus()) {
+ client::SetFocusClient(root_window(), nullptr);
+ client::SetCaptureClient(root_window(), nullptr);
+ host_.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();
- 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::ShutdownInputMethodForTesting();
if (env_)
« no previous file with comments | « no previous file | ui/views/BUILD.gn » ('j') | ui/views/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698