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

Side by Side Diff: services/ui/ws/window_tree_unittest.cc

Issue 2829733002: mus: Changes SetDisplayRoot() to create actual display (Closed)
Patch Set: unnecessary get Created 3 years, 8 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
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/ws/window_tree.h" 5 #include "services/ui/ws/window_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 WindowServerTestHelper ws_test_helper_; 1531 WindowServerTestHelper ws_test_helper_;
1532 TestScreenManager screen_manager_; 1532 TestScreenManager screen_manager_;
1533 1533
1534 DISALLOW_COPY_AND_ASSIGN(WindowTreeManualDisplayTest); 1534 DISALLOW_COPY_AND_ASSIGN(WindowTreeManualDisplayTest);
1535 }; 1535 };
1536 1536
1537 TEST_F(WindowTreeManualDisplayTest, ClientCreatesDisplayRoot) { 1537 TEST_F(WindowTreeManualDisplayTest, ClientCreatesDisplayRoot) {
1538 const bool automatically_create_display_roots = false; 1538 const bool automatically_create_display_roots = false;
1539 AddWindowManager(window_server(), kTestUserId1, 1539 AddWindowManager(window_server(), kTestUserId1,
1540 automatically_create_display_roots); 1540 automatically_create_display_roots);
1541 const int64_t display_id =
1542 screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
1543 WindowManagerState* window_manager_state = 1541 WindowManagerState* window_manager_state =
1544 window_server()->GetWindowManagerStateForUser(kTestUserId1); 1542 window_server()->GetWindowManagerStateForUser(kTestUserId1);
1545 ASSERT_TRUE(window_manager_state); 1543 ASSERT_TRUE(window_manager_state);
1546 WindowTree* window_manager_tree = window_manager_state->window_tree(); 1544 WindowTree* window_manager_tree = window_manager_state->window_tree();
1547 EXPECT_TRUE(window_manager_tree->roots().empty()); 1545 EXPECT_TRUE(window_manager_tree->roots().empty());
1548 TestWindowManager* test_window_manager = 1546 TestWindowManager* test_window_manager =
1549 window_server_delegate()->last_binding()->window_manager(); 1547 window_server_delegate()->last_binding()->window_manager();
1550 EXPECT_EQ(1, test_window_manager->connect_count()); 1548 EXPECT_EQ(1, test_window_manager->connect_count());
1551 EXPECT_EQ(0, test_window_manager->display_added_count()); 1549 EXPECT_EQ(0, test_window_manager->display_added_count());
1552 1550
1553 // Add another display and make sure WindowManager is not updated.
1554 screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
1555 EXPECT_EQ(0, test_window_manager->display_added_count());
1556
1557 // Create a window for the windowmanager and set it as the root. 1551 // Create a window for the windowmanager and set it as the root.
1558 ClientWindowId display_root_id = BuildClientWindowId(window_manager_tree, 10); 1552 ClientWindowId display_root_id = BuildClientWindowId(window_manager_tree, 10);
1559 ASSERT_TRUE(window_manager_tree->NewWindow(display_root_id, 1553 ASSERT_TRUE(window_manager_tree->NewWindow(display_root_id,
1560 ServerWindow::Properties())); 1554 ServerWindow::Properties()));
1561 ServerWindow* display_root = 1555 ServerWindow* display_root =
1562 window_manager_tree->GetWindowByClientId(display_root_id); 1556 window_manager_tree->GetWindowByClientId(display_root_id);
1563 ASSERT_TRUE(display_root); 1557 ASSERT_TRUE(display_root);
1558 display::Display display1 = MakeDisplay(0, 0, 1024, 768, 1.0f);
1559 display1.set_id(101);
1560
1561 mojom::WmViewportMetrics metrics;
1562 metrics.bounds_in_pixels = display1.bounds();
1563 metrics.device_scale_factor = 1.5;
1564 metrics.ui_scale_factor = 2.5;
1565 const bool is_primary_display = true;
1564 ASSERT_TRUE(WindowTreeTestApi(window_manager_tree) 1566 ASSERT_TRUE(WindowTreeTestApi(window_manager_tree)
1565 .ProcessSetDisplayRoot(display_id, display_root_id)); 1567 .ProcessSetDisplayRoot(display1, metrics, is_primary_display,
1568 display_root_id));
1566 EXPECT_TRUE(display_root->parent()); 1569 EXPECT_TRUE(display_root->parent());
1567 EXPECT_TRUE(window_server_delegate() 1570 EXPECT_TRUE(window_server_delegate()
1568 ->last_binding() 1571 ->last_binding()
1569 ->client() 1572 ->client()
1570 ->tracker() 1573 ->tracker()
1571 ->changes() 1574 ->changes()
1572 ->empty()); 1575 ->empty());
1573 ASSERT_EQ(1u, window_manager_tree->roots().size()); 1576 EXPECT_EQ(1u, window_manager_tree->roots().size());
1574 EXPECT_EQ(display_root, *window_manager_tree->roots().begin());
1575 ASSERT_EQ(2u, WindowManagerStateTestApi(window_manager_state)
1576 .window_manager_display_roots()
1577 .size());
1578 1577
1579 // Delete the root, which should delete the WindowManagerDisplayRoot. 1578 // Delete the root, which should delete the WindowManagerDisplayRoot.
1580 EXPECT_TRUE(window_manager_tree->DeleteWindow(display_root_id)); 1579 EXPECT_TRUE(window_manager_tree->DeleteWindow(display_root_id));
1581 ASSERT_TRUE(window_manager_tree->roots().empty()); 1580 EXPECT_TRUE(window_manager_tree->roots().empty());
1582 ASSERT_EQ(1u, WindowManagerStateTestApi(window_manager_state) 1581 EXPECT_TRUE(WindowManagerStateTestApi(window_manager_state)
1583 .window_manager_display_roots() 1582 .window_manager_display_roots()
1584 .size()); 1583 .empty());
1585 } 1584 }
1586 1585
1587 } // namespace test 1586 } // namespace test
1588 } // namespace ws 1587 } // namespace ws
1589 } // namespace ui 1588 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698