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

Unified Diff: mojo/services/view_manager/view_manager_service_apptest.cc

Issue 720883003: Adds a CloneAndAnimate function to WindowManagerInternalClient (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: feedback Created 6 years, 1 month 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: mojo/services/view_manager/view_manager_service_apptest.cc
diff --git a/mojo/services/view_manager/view_manager_service_apptest.cc b/mojo/services/view_manager/view_manager_service_apptest.cc
index b49221bc41b722d5af87652f71e4b8d94933a8d0..7270903f07747fa47655eb12c2c1e38d7650b972 100644
--- a/mojo/services/view_manager/view_manager_service_apptest.cc
+++ b/mojo/services/view_manager/view_manager_service_apptest.cc
@@ -171,6 +171,31 @@ bool SetViewProperty(ViewManagerService* vm,
return result;
}
+void CloneAndAnimate(WindowManagerInternalClient* wm, Id view_id) {
msw 2014/11/19 01:27:51 optional nit: remove this helper for now?
sky 2014/11/19 03:28:18 Done.
+ wm->CloneAndAnimate(view_id);
+}
+
+// Utility functions -----------------------------------------------------------
+
+// Waits for all messages to be received by |vm|. This is done by attempting to
+// create a bogus view. When we get the response we know all messages have been
+// processed.
+bool WaitForAllMessages(ViewManagerService* vm) {
+ ErrorCode result = ERROR_CODE_NONE;
+ base::RunLoop run_loop;
+ vm->CreateView(ViewIdToTransportId(InvalidViewId()),
+ base::Bind(&ErrorCodeResultCallback, &run_loop, &result));
+ run_loop.Run();
+ return result != ERROR_CODE_NONE;
+}
+
+bool HasClonedView(const std::vector<TestView>& views) {
+ for (size_t i = 0; i < views.size(); ++i)
+ if (views[i].view_id == ViewIdToTransportId(ClonedViewId()))
+ return true;
+ return false;
+}
+
// -----------------------------------------------------------------------------
// A ViewManagerClient implementation that logs all changes to a tracker.
@@ -1324,6 +1349,39 @@ TEST_F(ViewManagerServiceAppTest, DontCleanMapOnDestroy) {
EXPECT_FALSE(views.empty());
}
+TEST_F(ViewManagerServiceAppTest, CloneAndAnimate) {
+ // Create connection 2 and 3.
+ ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
+ ASSERT_TRUE(AddView(vm1(), BuildViewId(0, 1), BuildViewId(1, 1)));
+ ASSERT_TRUE(CreateView(vm2(), BuildViewId(2, 2)));
+ ASSERT_TRUE(CreateView(vm2(), BuildViewId(2, 3)));
+ ASSERT_TRUE(AddView(vm2(), BuildViewId(1, 1), BuildViewId(2, 2)));
+ ASSERT_TRUE(AddView(vm2(), BuildViewId(2, 2), BuildViewId(2, 3)));
+ changes2()->clear();
+
+ ASSERT_TRUE(WaitForAllMessages(vm1()));
+ changes1()->clear();
+
+ CloneAndAnimate(wm_internal_.get(), BuildViewId(2, 3));
+ ASSERT_TRUE(WaitForAllMessages(vm1()));
+
+ ASSERT_TRUE(WaitForAllMessages(vm1()));
+ ASSERT_TRUE(WaitForAllMessages(vm2()));
+
+ // No messages should have been received.
+ EXPECT_TRUE(changes1()->empty());
+ EXPECT_TRUE(changes2()->empty());
+
+ // No one should be able to see the cloned tree.
+ std::vector<TestView> views;
+ GetViewTree(vm1(), BuildViewId(1, 1), &views);
+ EXPECT_FALSE(HasClonedView(views));
+ views.clear();
+
+ GetViewTree(vm2(), BuildViewId(1, 1), &views);
+ EXPECT_FALSE(HasClonedView(views));
+}
+
// TODO(sky): need to better track changes to initial connection. For example,
// that SetBounsdViews/AddView and the like don't result in messages to the
// originating connection.

Powered by Google App Engine
This is Rietveld 408576698