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

Unified Diff: services/ui/view_manager/tests/view_associate_table_test.cc

Issue 1949233002: Create a RegisterViewAssociate method in ViewManager (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add tests to mojo tests Created 4 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
Index: services/ui/view_manager/tests/view_associate_table_test.cc
diff --git a/services/ui/view_manager/tests/view_associate_table_test.cc b/services/ui/view_manager/tests/view_associate_table_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..01eb4b357f40b8db014276be22871662dba22cb0
--- /dev/null
+++ b/services/ui/view_manager/tests/view_associate_table_test.cc
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/services/ui/views/interfaces/view_manager.mojom.h"
+#include "mojo/services/ui/views/interfaces/views.mojom.h"
+#include "mojo/ui/associates/mock_view_inspector.h"
+#include "services/ui/view_manager/tests/mock_view_associate.h"
+#include "services/ui/view_manager/tests/view_manager_test_base.h"
+#include "services/ui/view_manager/view_associate_table.h"
+
+namespace view_manager {
+namespace test {
+
+class ViewAssociateTableTest : public ViewManagerTestBase {
+ public:
+ ViewAssociateTableTest() {}
+ ~ViewAssociateTableTest() override {}
+
+ void SetUp() override { ViewManagerTestBase::SetUp(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ViewAssociateTableTest);
+};
+
+TEST_F(ViewAssociateTableTest, RegisterViewAssociateThenCloseIt) {
+ // Create a mock view registry
+ mojo::ui::MockViewInspector mock_view_inspector;
+
+ // Create a view associate table
+ ViewAssociateTable view_associate_table;
+
+ {
+ // Create and bind a MockViewAssociate
+ mojo::ui::ViewAssociatePtr associate;
+ MockViewAssociate mock_view_associate;
+ mojo::Binding<mojo::ui::ViewAssociate> view_associate_binding(
+ &mock_view_associate, mojo::GetProxy(&associate));
+
+ // call ViewAssociateTable::RegisterViewAssociate
+ EXPECT_EQ((size_t)0, view_associate_table.associate_count());
+
+ mojo::ui::ViewAssociateOwnerPtr view_associate_owner;
+ view_associate_table.RegisterViewAssociate(
+ &mock_view_inspector, associate.Pass(),
+ mojo::GetProxy(&view_associate_owner), "test_view_associate");
+ KICK_MESSAGE_LOOP_WHILE(view_associate_table.associate_count() != 1);
+ EXPECT_EQ((size_t)1, view_associate_table.associate_count());
+ }
+
+ // ViewAssociate has been destroyed (since it's out of scope now)
+ // Make sure it's been removed
+ KICK_MESSAGE_LOOP_WHILE(view_associate_table.associate_count() != 0);
+ EXPECT_EQ((size_t)0, view_associate_table.associate_count());
+}
+
+} // namespace test
+} // namespace view_manager
« no previous file with comments | « services/ui/view_manager/tests/mock_view_associate.cc ('k') | services/ui/view_manager/tests/view_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698