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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h"
6 #include "mojo/services/ui/views/interfaces/views.mojom.h"
7 #include "mojo/ui/associates/mock_view_inspector.h"
8 #include "services/ui/view_manager/tests/mock_view_associate.h"
9 #include "services/ui/view_manager/tests/view_manager_test_base.h"
10 #include "services/ui/view_manager/view_associate_table.h"
11
12 namespace view_manager {
13 namespace test {
14
15 class ViewAssociateTableTest : public ViewManagerTestBase {
16 public:
17 ViewAssociateTableTest() {}
18 ~ViewAssociateTableTest() override {}
19
20 void SetUp() override { ViewManagerTestBase::SetUp(); }
21
22 private:
23 DISALLOW_COPY_AND_ASSIGN(ViewAssociateTableTest);
24 };
25
26 TEST_F(ViewAssociateTableTest, RegisterViewAssociateThenCloseIt) {
27 // Create a mock view registry
28 mojo::ui::MockViewInspector mock_view_inspector;
29
30 // Create a view associate table
31 ViewAssociateTable view_associate_table;
32
33 {
34 // Create and bind a MockViewAssociate
35 mojo::ui::ViewAssociatePtr associate;
36 MockViewAssociate mock_view_associate;
37 mojo::Binding<mojo::ui::ViewAssociate> view_associate_binding(
38 &mock_view_associate, mojo::GetProxy(&associate));
39
40 // call ViewAssociateTable::RegisterViewAssociate
41 EXPECT_EQ((size_t)0, view_associate_table.associate_count());
42
43 mojo::ui::ViewAssociateOwnerPtr view_associate_owner;
44 view_associate_table.RegisterViewAssociate(
45 &mock_view_inspector, associate.Pass(),
46 mojo::GetProxy(&view_associate_owner), "test_view_associate");
47 KICK_MESSAGE_LOOP_WHILE(view_associate_table.associate_count() != 1);
48 EXPECT_EQ((size_t)1, view_associate_table.associate_count());
49 }
50
51 // ViewAssociate has been destroyed (since it's out of scope now)
52 // Make sure it's been removed
53 KICK_MESSAGE_LOOP_WHILE(view_associate_table.associate_count() != 0);
54 EXPECT_EQ((size_t)0, view_associate_table.associate_count());
55 }
56
57 } // namespace test
58 } // namespace view_manager
OLDNEW
« 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