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

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

Issue 287183003: Restricts node/view deletion to creator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 7 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 | « mojo/services/view_manager/view_manager_connection.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/view_manager/view_manager_connection_unittest.cc
diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc
index 3b920a8719d14cc40ee14532a1347be4581b7a95..8d8458d9a766457f8160c373d3643192bdd08bb0 100644
--- a/mojo/services/view_manager/view_manager_connection_unittest.cc
+++ b/mojo/services/view_manager/view_manager_connection_unittest.cc
@@ -105,7 +105,7 @@ bool CreateNode(IViewManager* view_manager,
return result;
}
-// Deletes a node, blocking until done.
+// Deletes a view, blocking until done.
bool DeleteNode(IViewManager* view_manager, TransportNodeId node_id) {
bool result = false;
view_manager->DeleteNode(node_id, base::Bind(&BooleanCallback, &result));
@@ -113,6 +113,14 @@ bool DeleteNode(IViewManager* view_manager, TransportNodeId node_id) {
return result;
}
+// Deletes a node, blocking until done.
+bool DeleteView(IViewManager* view_manager, TransportViewId view_id) {
+ bool result = false;
+ view_manager->DeleteView(view_id, base::Bind(&BooleanCallback, &result));
+ DoRunLoop();
+ return result;
+}
+
// Adds a node, blocking until done.
bool AddNode(IViewManager* view_manager,
TransportNodeId parent,
@@ -803,6 +811,20 @@ TEST_F(ViewManagerConnectionTest, DeleteNode) {
}
}
+// Verifies DeleteNode isn't allowed from a separate connection.
+TEST_F(ViewManagerConnectionTest, DeleteNodeFromAnotherConnectionDisallowed) {
+ ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
+ EstablishSecondConnection();
+ EXPECT_FALSE(DeleteNode(view_manager2_.get(), CreateNodeId(client_.id(), 1)));
+}
+
+// Verifies DeleteView isn't allowed from a separate connection.
+TEST_F(ViewManagerConnectionTest, DeleteViewFromAnotherConnectionDisallowed) {
+ ASSERT_TRUE(CreateView(view_manager_.get(), 1, 1));
+ EstablishSecondConnection();
+ EXPECT_FALSE(DeleteView(view_manager2_.get(), CreateViewId(client_.id(), 1)));
+}
+
// Verifies if a node was deleted and then reused that other clients are
// properly notified.
TEST_F(ViewManagerConnectionTest, ReusedDeletedId) {
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698