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

Unified Diff: services/ui/demo/mus_demo_unittests.cc

Issue 2715533005: Make mus_demo_unittests work with multiple root windows (Closed)
Patch Set: Add a unit test for multiple windows. Created 3 years, 10 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: services/ui/demo/mus_demo_unittests.cc
diff --git a/services/ui/demo/mus_demo_unittests.cc b/services/ui/demo/mus_demo_unittests.cc
index 9fdb8107a2c0aff014de2d237164dce0aaecd753..827e92520e567371b008e7fac58373a76ccfeef9 100644
--- a/services/ui/demo/mus_demo_unittests.cc
+++ b/services/ui/demo/mus_demo_unittests.cc
@@ -18,8 +18,10 @@ namespace {
const char kTestAppName[] = "mus_demo_unittests";
-void RunCallback(bool* success, const base::Closure& callback, bool result) {
- *success = result;
+void RunCallback(uint64_t* root_window_count,
+ const base::Closure& callback,
+ uint64_t result) {
+ *root_window_count = result;
callback.Run();
}
@@ -33,6 +35,26 @@ class MusDemoTest : public service_manager::test::ServiceTest {
ServiceTest::SetUp();
}
+ protected:
+ uint64_t StartDemoAndCountDrawnWindows() {
+ connector()->Connect("mus_demo");
+
+ ::ui::mojom::WindowServerTestPtr test_interface;
+ connector()->BindInterface(ui::mojom::kServiceName, &test_interface);
+
+ base::RunLoop run_loop;
+ uint64_t root_window_count = 0;
+ // TODO(kylechar): Fix WindowServer::CreateTreeForWindowManager so that the
+ // WindowTree has the correct name instead of an empty name.
+ // TODO(tonikitoo,fwang): Also fix the WindowTree name for MusDemoExternal.
+ test_interface->EnsureClientHasDrawnRootWindows(
+ "", // WindowTree name is empty.
+ base::Bind(&RunCallback, &root_window_count, run_loop.QuitClosure()));
+ run_loop.Run();
+
+ return root_window_count;
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(MusDemoTest);
};
@@ -40,21 +62,17 @@ class MusDemoTest : public service_manager::test::ServiceTest {
} // namespace
TEST_F(MusDemoTest, CheckMusDemoDraws) {
- connector()->Connect("mus_demo");
-
- ::ui::mojom::WindowServerTestPtr test_interface;
- connector()->BindInterface(ui::mojom::kServiceName, &test_interface);
-
- base::RunLoop run_loop;
- bool success = false;
- // TODO(kylechar): Fix WindowServer::CreateTreeForWindowManager so that the
- // WindowTree has the correct name instead of an empty name.
- test_interface->EnsureClientHasDrawnWindow(
- "", // WindowTree name is empty.
- base::Bind(&RunCallback, &success, run_loop.QuitClosure()));
- run_loop.Run();
- EXPECT_TRUE(success);
+ EXPECT_EQ(1u, StartDemoAndCountDrawnWindows());
+}
+
+#if defined(USE_OZONE) && !defined(OS_CHROMEOS)
+TEST_F(MusDemoTest, CheckMusDemoMultipleWindows) {
+ uint64_t expected_root_window_count = 5;
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ "external-window-count", std::to_string(expected_root_window_count));
+ EXPECT_EQ(expected_root_window_count, StartDemoAndCountDrawnWindows());
}
+#endif // defined(USE_OZONE) && !defined(OS_CHROMEOS)
} // namespace demo
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698