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

Unified Diff: components/mus/view_tree_apptest.cc

Issue 1352043005: mus: Implement Window Server Capture Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 5 years, 3 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: components/mus/view_tree_apptest.cc
diff --git a/components/mus/view_tree_apptest.cc b/components/mus/view_tree_apptest.cc
index dfef44ec5589e3de604abe610619240898aa6d7a..7f7a5129570f68f9c1934bb175461eb4b628931b 100644
--- a/components/mus/view_tree_apptest.cc
+++ b/components/mus/view_tree_apptest.cc
@@ -162,6 +162,14 @@ bool DeleteView(ViewTree* vm, Id view_id) {
return result;
}
+bool SetViewCapture(ViewTree* vm, Id view_id) {
+ base::RunLoop run_loop;
+ bool result = false;
+ vm->SetCapture(view_id, base::Bind(&BoolResultCallback, &run_loop, &result));
+ run_loop.Run();
+ return result;
+}
+
bool SetViewBounds(ViewTree* vm, Id view_id, int x, int y, int w, int h) {
base::RunLoop run_loop;
bool result = false;
@@ -316,6 +324,7 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
tracker()->OnEmbeddedAppDisconnected(view_id);
}
void OnUnembed() override { tracker()->OnUnembed(); }
+ void OnLostCapture(Id view_id) override { tracker()->OnLostCapture(view_id); }
void OnViewBoundsChanged(Id view_id,
RectPtr old_bounds,
RectPtr new_bounds) override {
@@ -1667,6 +1676,22 @@ TEST_F(ViewTreeAppTest, CantEmbedFromConnectionRoot) {
EmbedUrl(application_impl(), vm3(), application_impl()->url(), view_1_2));
}
+TEST_F(ViewTreeAppTest, CapturePropagation) {
+ Id view_1_1 = vm_client1()->CreateView(1);
+ Id view_1_2 = vm_client1()->CreateView(2);
+ changes1()->clear();
+ // View 1 takes capture then View 2 takes capture.
+ // Verify that view 1 has lost capture.
+ SetViewCapture(vm1(), view_1_1);
+ SetViewCapture(vm1(), view_1_2);
sadrul 2015/09/18 01:30:50 What if the two setcapture calls come from two sep
Fady Samuel 2015/09/18 02:44:43 So two separate windows? If one tries to capture,
sadrul 2015/09/18 11:47:28 Yep. (in most cases anyway. The second capture can
+ vm_client1_->WaitForChangeCount(1);
+
+ EXPECT_EQ("OnLostCapture view=" + IdToString(view_1_1),
+ SingleChangeToDescription(*changes1()));
+ // std::vector<TestView> views;
+ // GetViewTree(vm1(), view_1_1, &views);
+ // EXPECT_FALSE(views.empty());
+}
sadrul 2015/09/18 01:30:50 ?
Fady Samuel 2015/09/18 02:44:43 Removed.
// 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