OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/public/cpp/lib/window_tree_client_impl.h" | 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // Destroying the window triggers | 485 // Destroying the window triggers |
486 // ToggleVisibilityFromDestroyedObserver::OnWindowDestroyed(), which toggles | 486 // ToggleVisibilityFromDestroyedObserver::OnWindowDestroyed(), which toggles |
487 // the visibility of the window. Ack the change, which should not crash or | 487 // the visibility of the window. Ack the change, which should not crash or |
488 // trigger DCHECKs. | 488 // trigger DCHECKs. |
489 child1->Destroy(); | 489 child1->Destroy(); |
490 uint32_t change_id; | 490 uint32_t change_id; |
491 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); | 491 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); |
492 setup.window_tree_client()->OnChangeCompleted(change_id, true); | 492 setup.window_tree_client()->OnChangeCompleted(change_id, true); |
493 } | 493 } |
494 | 494 |
| 495 TEST_F(WindowTreeClientImplTest, NewTopLevelWindow) { |
| 496 WindowTreeSetup setup; |
| 497 Window* root1 = setup.GetFirstRoot(); |
| 498 ASSERT_TRUE(root1); |
| 499 Window* root2 = setup.window_tree_connection()->NewTopLevelWindow(nullptr); |
| 500 ASSERT_TRUE(root2); |
| 501 ASSERT_NE(root2, root1); |
| 502 EXPECT_NE(root2->id(), root1->id()); |
| 503 EXPECT_EQ(2u, setup.window_tree_connection()->GetRoots().size()); |
| 504 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root1) > 0u); |
| 505 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root2) > 0u); |
| 506 |
| 507 // Ack the request to the windowtree to create the new window. |
| 508 uint32_t change_id; |
| 509 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); |
| 510 EXPECT_EQ(setup.window_tree()->window_id(), root2->id()); |
| 511 setup.window_tree_client()->OnChangeCompleted(change_id, true); |
| 512 |
| 513 // Should not be able to add a top level as a child of another window. |
| 514 root1->AddChild(root2); |
| 515 ASSERT_EQ(nullptr, root2->parent()); |
| 516 |
| 517 // Destroy the first root, shouldn't initiate tear down. |
| 518 root1->Destroy(); |
| 519 root1 = nullptr; |
| 520 EXPECT_EQ(1u, setup.window_tree_connection()->GetRoots().size()); |
| 521 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root2) > 0u); |
| 522 } |
| 523 |
495 } // namespace mus | 524 } // namespace mus |
OLD | NEW |