OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 #include "mojo/public/cpp/application/application_test_base.h" | 10 #include "mojo/public/cpp/application/application_test_base.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 // block until call completes and return the result. | 73 // block until call completes and return the result. |
74 bool CreateView(ViewManagerService* vm, Id view_id) { | 74 bool CreateView(ViewManagerService* vm, Id view_id) { |
75 ErrorCode result = ERROR_CODE_NONE; | 75 ErrorCode result = ERROR_CODE_NONE; |
76 base::RunLoop run_loop; | 76 base::RunLoop run_loop; |
77 vm->CreateView(view_id, | 77 vm->CreateView(view_id, |
78 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); | 78 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); |
79 run_loop.Run(); | 79 run_loop.Run(); |
80 return result == ERROR_CODE_NONE; | 80 return result == ERROR_CODE_NONE; |
81 } | 81 } |
82 | 82 |
83 bool Embed(ViewManagerService* vm, Id root_id) { | 83 bool Embed(ViewManagerService* vm, Id root_id) { |
msw
2015/02/09 19:44:13
nit: rename EmbedUrl to avoid overloading the new
sky
2015/02/10 00:12:59
Done.
| |
84 bool result = false; | 84 bool result = false; |
85 base::RunLoop run_loop; | 85 base::RunLoop run_loop; |
86 { | 86 { |
87 vm->Embed("mojo:view_manager_service_apptests", root_id, nullptr, nullptr, | 87 vm->EmbedUrl("mojo:view_manager_service_apptests", root_id, nullptr, |
88 nullptr, base::Bind(&BoolResultCallback, &run_loop, &result)); | |
89 } | |
90 run_loop.Run(); | |
91 return result; | |
92 } | |
93 | |
94 bool Embed(ViewManagerService* vm, | |
95 Id root_id, | |
96 mojo::ViewManagerClientPtr client) { | |
97 bool result = false; | |
98 base::RunLoop run_loop; | |
99 { | |
100 vm->Embed(root_id, client.Pass(), | |
88 base::Bind(&BoolResultCallback, &run_loop, &result)); | 101 base::Bind(&BoolResultCallback, &run_loop, &result)); |
89 } | 102 } |
90 run_loop.Run(); | 103 run_loop.Run(); |
91 return result; | 104 return result; |
92 } | 105 } |
93 | 106 |
94 ErrorCode CreateViewWithErrorCode(ViewManagerService* vm, Id view_id) { | 107 ErrorCode CreateViewWithErrorCode(ViewManagerService* vm, Id view_id) { |
95 ErrorCode result = ERROR_CODE_NONE; | 108 ErrorCode result = ERROR_CODE_NONE; |
96 base::RunLoop run_loop; | 109 base::RunLoop run_loop; |
97 vm->CreateView(view_id, | 110 vm->CreateView(view_id, |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1314 // Add 1,1 back to the root, connection 2 should see drawn state changed. | 1327 // Add 1,1 back to the root, connection 2 should see drawn state changed. |
1315 ASSERT_TRUE(AddView(vm1(), BuildViewId(0, 1), BuildViewId(1, 1))); | 1328 ASSERT_TRUE(AddView(vm1(), BuildViewId(0, 1), BuildViewId(1, 1))); |
1316 { | 1329 { |
1317 vm_client2_->WaitForChangeCount(1); | 1330 vm_client2_->WaitForChangeCount(1); |
1318 EXPECT_EQ("DrawnStateChanged view=1,2 drawn=true", | 1331 EXPECT_EQ("DrawnStateChanged view=1,2 drawn=true", |
1319 SingleChangeToDescription(*changes2())); | 1332 SingleChangeToDescription(*changes2())); |
1320 } | 1333 } |
1321 } | 1334 } |
1322 | 1335 |
1323 TEST_F(ViewManagerServiceAppTest, SetViewProperty) { | 1336 TEST_F(ViewManagerServiceAppTest, SetViewProperty) { |
1324 // Create 1 and 2 in the first connection and parent both to the root. | 1337 // Create 1 and 2 in the first connection and parent both to the root. |
msw
2015/02/09 19:44:13
nit: This doesn't seem to create or add |2|, just
| |
1325 ASSERT_TRUE(CreateView(vm1(), BuildViewId(1, 1))); | 1338 ASSERT_TRUE(CreateView(vm1(), BuildViewId(1, 1))); |
1326 | 1339 |
1327 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 1340 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
1328 changes2()->clear(); | 1341 changes2()->clear(); |
1329 | 1342 |
1330 ASSERT_TRUE(AddView(vm1(), BuildViewId(0, 1), BuildViewId(1, 1))); | 1343 ASSERT_TRUE(AddView(vm1(), BuildViewId(0, 1), BuildViewId(1, 1))); |
1331 { | 1344 { |
1332 std::vector<TestView> views; | 1345 std::vector<TestView> views; |
1333 GetViewTree(vm1(), BuildViewId(0, 1), &views); | 1346 GetViewTree(vm1(), BuildViewId(0, 1), &views); |
1334 ASSERT_EQ(2u, views.size()); | 1347 ASSERT_EQ(2u, views.size()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1443 // No one should be able to see the cloned tree. | 1456 // No one should be able to see the cloned tree. |
1444 std::vector<TestView> views; | 1457 std::vector<TestView> views; |
1445 GetViewTree(vm1(), BuildViewId(1, 1), &views); | 1458 GetViewTree(vm1(), BuildViewId(1, 1), &views); |
1446 EXPECT_FALSE(HasClonedView(views)); | 1459 EXPECT_FALSE(HasClonedView(views)); |
1447 views.clear(); | 1460 views.clear(); |
1448 | 1461 |
1449 GetViewTree(vm2(), BuildViewId(1, 1), &views); | 1462 GetViewTree(vm2(), BuildViewId(1, 1), &views); |
1450 EXPECT_FALSE(HasClonedView(views)); | 1463 EXPECT_FALSE(HasClonedView(views)); |
1451 } | 1464 } |
1452 | 1465 |
1466 // Verifies Embed() works when supplying a ViewManagerClient. | |
1467 TEST_F(ViewManagerServiceAppTest, EmbedSupplyingViewManagerClient) { | |
1468 // Create 1 and 2 in the first connection and parent both to the root. | |
msw
2015/02/09 19:44:12
nit: This doesn't seem to create or add |2|, just
sky
2015/02/10 00:12:59
I nuked the comment (here and above). It wasn't re
| |
1469 ASSERT_TRUE(CreateView(vm1(), BuildViewId(1, 1))); | |
1470 | |
1471 ViewManagerClientImpl client2; | |
1472 mojo::ViewManagerClientPtr client2_ptr; | |
1473 mojo::Binding<ViewManagerClient> client2_binding(&client2, &client2_ptr); | |
1474 ASSERT_TRUE(Embed(vm1(), BuildViewId(1, 1), client2_ptr.Pass())); | |
1475 client2.WaitForOnEmbed(); | |
1476 EXPECT_EQ("OnEmbed creator=mojo:window_manager", | |
1477 SingleChangeToDescription(*client2.tracker()->changes())); | |
1478 } | |
1479 | |
1453 // TODO(sky): need to better track changes to initial connection. For example, | 1480 // TODO(sky): need to better track changes to initial connection. For example, |
1454 // that SetBounsdViews/AddView and the like don't result in messages to the | 1481 // that SetBounsdViews/AddView and the like don't result in messages to the |
1455 // originating connection. | 1482 // originating connection. |
1456 | 1483 |
1457 // TODO(sky): make sure coverage of what was | 1484 // TODO(sky): make sure coverage of what was |
1458 // ViewManagerTest.SecondEmbedRoot_InitService and | 1485 // ViewManagerTest.SecondEmbedRoot_InitService and |
1459 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager | 1486 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager |
1460 // tests. | 1487 // tests. |
1461 | 1488 |
1462 } // namespace view_manager | 1489 } // namespace view_manager |
OLD | NEW |