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

Side by Side Diff: services/view_manager/view_manager_service_unittest.cc

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/public/interfaces/application/service_provider.mojom.h" 10 #include "mojo/public/interfaces/application/service_provider.mojom.h"
11 #include "mojo/services/view_manager/public/cpp/types.h" 11 #include "mojo/services/view_manager/public/cpp/types.h"
12 #include "mojo/services/view_manager/public/cpp/util.h" 12 #include "mojo/services/view_manager/public/cpp/util.h"
13 #include "mojo/services/view_manager/public/interfaces/view_manager.mojom.h" 13 #include "mojo/services/view_manager/public/interfaces/view_manager.mojom.h"
14 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" 14 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h"
15 #include "mojo/services/window_manager/public/interfaces/window_manager_internal .mojom.h" 15 #include "mojo/services/window_manager/public/interfaces/window_manager_internal .mojom.h"
16 #include "services/view_manager/client_connection.h" 16 #include "services/view_manager/client_connection.h"
17 #include "services/view_manager/connection_manager.h" 17 #include "services/view_manager/connection_manager.h"
18 #include "services/view_manager/connection_manager_delegate.h" 18 #include "services/view_manager/connection_manager_delegate.h"
19 #include "services/view_manager/display_manager.h" 19 #include "services/view_manager/display_manager.h"
20 #include "services/view_manager/ids.h" 20 #include "services/view_manager/ids.h"
21 #include "services/view_manager/server_view.h" 21 #include "services/view_manager/server_view.h"
22 #include "services/view_manager/test_change_tracker.h" 22 #include "services/view_manager/test_change_tracker.h"
23 #include "services/view_manager/view_manager_service_impl.h" 23 #include "services/view_manager/view_manager_service_impl.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
26 26
27 using mojo::Array; 27 using mojo::Array;
28 using mojo::ERROR_CODE_NONE; 28 using mojo::ErrorCode;
29 using mojo::InterfaceRequest; 29 using mojo::InterfaceRequest;
30 using mojo::ServiceProvider; 30 using mojo::ServiceProvider;
31 using mojo::ServiceProviderPtr; 31 using mojo::ServiceProviderPtr;
32 using mojo::String; 32 using mojo::String;
33 using mojo::ViewDataPtr; 33 using mojo::ViewDataPtr;
34 34
35 namespace view_manager { 35 namespace view_manager {
36 namespace { 36 namespace {
37 37
38 // ----------------------------------------------------------------------------- 38 // -----------------------------------------------------------------------------
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 // Provides common setup for animation tests. Creates the following views: 282 // Provides common setup for animation tests. Creates the following views:
283 // 0,1 (the root, provided by view manager) 283 // 0,1 (the root, provided by view manager)
284 // 1,1 the second connection is embedded here (view owned by wm_connection()). 284 // 1,1 the second connection is embedded here (view owned by wm_connection()).
285 // 2,1 bounds=1,2 11x22 285 // 2,1 bounds=1,2 11x22
286 // 2,2 bounds=2,3 6x7 286 // 2,2 bounds=2,3 6x7
287 // 2,3 bounds=3,4 6x7 287 // 2,3 bounds=3,4 6x7
288 // CloneAndAnimate() is invoked for 2,2. 288 // CloneAndAnimate() is invoked for 2,2.
289 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) { 289 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) {
290 *embed_view_id = ViewId(test->wm_connection()->id(), 1); 290 *embed_view_id = ViewId(test->wm_connection()->id(), 1);
291 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id)); 291 EXPECT_EQ(ErrorCode::NONE, test->wm_connection()->CreateView(*embed_view_id));
292 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true)); 292 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true));
293 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()), 293 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()),
294 *embed_view_id)); 294 *embed_view_id));
295 test->wm_connection()->EmbedUrl(std::string(), *embed_view_id, nullptr, 295 test->wm_connection()->EmbedUrl(std::string(), *embed_view_id, nullptr,
296 nullptr); 296 nullptr);
297 ViewManagerServiceImpl* connection1 = 297 ViewManagerServiceImpl* connection1 =
298 test->connection_manager()->GetConnectionWithRoot(*embed_view_id); 298 test->connection_manager()->GetConnectionWithRoot(*embed_view_id);
299 ASSERT_TRUE(connection1 != nullptr); 299 ASSERT_TRUE(connection1 != nullptr);
300 ASSERT_NE(connection1, test->wm_connection()); 300 ASSERT_NE(connection1, test->wm_connection());
301 301
302 const ViewId child1(connection1->id(), 1); 302 const ViewId child1(connection1->id(), 1);
303 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); 303 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child1));
304 const ViewId child2(connection1->id(), 2); 304 const ViewId child2(connection1->id(), 2);
305 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); 305 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child2));
306 const ViewId child3(connection1->id(), 3); 306 const ViewId child3(connection1->id(), 3);
307 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3)); 307 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child3));
308 308
309 ServerView* v1 = connection1->GetView(child1); 309 ServerView* v1 = connection1->GetView(child1);
310 v1->SetVisible(true); 310 v1->SetVisible(true);
311 v1->SetBounds(gfx::Rect(1, 2, 11, 22)); 311 v1->SetBounds(gfx::Rect(1, 2, 11, 22));
312 ServerView* v2 = connection1->GetView(child2); 312 ServerView* v2 = connection1->GetView(child2);
313 v2->SetVisible(true); 313 v2->SetVisible(true);
314 v2->SetBounds(gfx::Rect(2, 3, 6, 7)); 314 v2->SetBounds(gfx::Rect(2, 3, 6, 7));
315 ServerView* v3 = connection1->GetView(child3); 315 ServerView* v3 = connection1->GetView(child3);
316 v3->SetVisible(true); 316 v3->SetVisible(true);
317 v3->SetBounds(gfx::Rect(3, 4, 6, 7)); 317 v3->SetBounds(gfx::Rect(3, 4, 6, 7));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 ASSERT_EQ(1u, cloned_view->GetChildren().size()); 418 ASSERT_EQ(1u, cloned_view->GetChildren().size());
419 EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId()); 419 EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
420 EXPECT_EQ(2u, cloned_view->parent()->GetChildren().size()); 420 EXPECT_EQ(2u, cloned_view->parent()->GetChildren().size());
421 EXPECT_TRUE(cloned_view->parent()->GetChildren()[1] == cloned_view); 421 EXPECT_TRUE(cloned_view->parent()->GetChildren()[1] == cloned_view);
422 } 422 }
423 423
424 // Clone and animate on a tree with more depth. Basically that of 424 // Clone and animate on a tree with more depth. Basically that of
425 // SetUpAnimate1() but cloning 2,1. 425 // SetUpAnimate1() but cloning 2,1.
426 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) { 426 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) {
427 const ViewId embed_view_id(wm_connection()->id(), 1); 427 const ViewId embed_view_id(wm_connection()->id(), 1);
428 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); 428 EXPECT_EQ(ErrorCode::NONE, wm_connection()->CreateView(embed_view_id));
429 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); 429 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
430 EXPECT_TRUE( 430 EXPECT_TRUE(
431 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); 431 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
432 wm_connection()->EmbedUrl(std::string(), embed_view_id, nullptr, nullptr); 432 wm_connection()->EmbedUrl(std::string(), embed_view_id, nullptr, nullptr);
433 ViewManagerServiceImpl* connection1 = 433 ViewManagerServiceImpl* connection1 =
434 connection_manager()->GetConnectionWithRoot(embed_view_id); 434 connection_manager()->GetConnectionWithRoot(embed_view_id);
435 ASSERT_TRUE(connection1 != nullptr); 435 ASSERT_TRUE(connection1 != nullptr);
436 ASSERT_NE(connection1, wm_connection()); 436 ASSERT_NE(connection1, wm_connection());
437 437
438 const ViewId child1(connection1->id(), 1); 438 const ViewId child1(connection1->id(), 1);
439 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); 439 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child1));
440 const ViewId child2(connection1->id(), 2); 440 const ViewId child2(connection1->id(), 2);
441 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); 441 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child2));
442 const ViewId child3(connection1->id(), 3); 442 const ViewId child3(connection1->id(), 3);
443 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3)); 443 EXPECT_EQ(ErrorCode::NONE, connection1->CreateView(child3));
444 444
445 ServerView* v1 = connection1->GetView(child1); 445 ServerView* v1 = connection1->GetView(child1);
446 v1->SetVisible(true); 446 v1->SetVisible(true);
447 connection1->GetView(child2)->SetVisible(true); 447 connection1->GetView(child2)->SetVisible(true);
448 connection1->GetView(child3)->SetVisible(true); 448 connection1->GetView(child3)->SetVisible(true);
449 449
450 EXPECT_TRUE(connection1->AddView(embed_view_id, child1)); 450 EXPECT_TRUE(connection1->AddView(embed_view_id, child1));
451 EXPECT_TRUE(connection1->AddView(child1, child2)); 451 EXPECT_TRUE(connection1->AddView(child1, child2));
452 EXPECT_TRUE(connection1->AddView(child2, child3)); 452 EXPECT_TRUE(connection1->AddView(child2, child3));
453 453
454 TestViewManagerClient* connection1_client = last_view_manager_client(); 454 TestViewManagerClient* connection1_client = last_view_manager_client();
455 connection1_client->tracker()->changes()->clear(); 455 connection1_client->tracker()->changes()->clear();
456 wm_client()->tracker()->changes()->clear(); 456 wm_client()->tracker()->changes()->clear();
457 EXPECT_TRUE(connection_manager()->CloneAndAnimate(child1)); 457 EXPECT_TRUE(connection_manager()->CloneAndAnimate(child1));
458 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); 458 EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
459 EXPECT_TRUE(wm_client()->tracker()->changes()->empty()); 459 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
460 460
461 // We cloned v1. The cloned view ends up as a sibling of it. 461 // We cloned v1. The cloned view ends up as a sibling of it.
462 const ServerView* cloned_view = GetFirstCloned(v1->parent()); 462 const ServerView* cloned_view = GetFirstCloned(v1->parent());
463 ASSERT_TRUE(cloned_view); 463 ASSERT_TRUE(cloned_view);
464 // |cloned_view| should have a child and its child should have a child. 464 // |cloned_view| should have a child and its child should have a child.
465 ASSERT_EQ(1u, cloned_view->GetChildren().size()); 465 ASSERT_EQ(1u, cloned_view->GetChildren().size());
466 const ServerView* cloned_view_child = cloned_view->GetChildren()[0]; 466 const ServerView* cloned_view_child = cloned_view->GetChildren()[0];
467 EXPECT_EQ(1u, cloned_view_child->GetChildren().size()); 467 EXPECT_EQ(1u, cloned_view_child->GetChildren().size());
468 EXPECT_TRUE(cloned_view_child->id() == ClonedViewId()); 468 EXPECT_TRUE(cloned_view_child->id() == ClonedViewId());
469 } 469 }
470 470
471 } // namespace view_manager 471 } // namespace view_manager
OLDNEW
« no previous file with comments | « services/view_manager/view_manager_service_impl.cc ('k') | shell/application_manager/network_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698