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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2886873002: Only send the FrameSinkId to client when it is necessary (Closed)
Patch Set: Address review issues. Created 3 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
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/mus/window_tree_host_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 // Ack the request to the windowtree to create the new window. 1429 // Ack the request to the windowtree to create the new window.
1430 uint32_t change_id; 1430 uint32_t change_id;
1431 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1431 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1432 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1432 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1433 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 1433 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
1434 1434
1435 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1435 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1436 data->window_id = server_id(top_level); 1436 data->window_id = server_id(top_level);
1437 const int64_t display_id = 1; 1437 const int64_t display_id = 1;
1438 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1438 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
1439 display_id, false, 1439 display_id, false, base::nullopt);
1440 cc::FrameSinkId(1, 1), base::nullopt);
1441 1440
1442 EXPECT_FALSE(window_tree_host->window()->TargetVisibility()); 1441 EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
1443 1442
1444 // Should not be able to add a top level as a child of another window. 1443 // Should not be able to add a top level as a child of another window.
1445 // TODO(sky): decide how to handle this. 1444 // TODO(sky): decide how to handle this.
1446 // root_window()->AddChild(top_level); 1445 // root_window()->AddChild(top_level);
1447 // ASSERT_EQ(nullptr, top_level->parent()); 1446 // ASSERT_EQ(nullptr, top_level->parent());
1448 1447
1449 // Destroy the first root, shouldn't initiate tear down. 1448 // Destroy the first root, shouldn't initiate tear down.
1450 window_tree_host.reset(); 1449 window_tree_host.reset();
(...skipping 20 matching lines...) Expand all
1471 1470
1472 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 1471 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
1473 data->window_id = server_id(top_level); 1472 data->window_id = server_id(top_level);
1474 data->bounds.SetRect(1, 2, 3, 4); 1473 data->bounds.SetRect(1, 2, 3, 4);
1475 data->visible = true; 1474 data->visible = true;
1476 const int64_t display_id = 10; 1475 const int64_t display_id = 10;
1477 uint32_t change_id; 1476 uint32_t change_id;
1478 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1477 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1479 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1478 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1480 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1479 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
1481 display_id, true, 1480 display_id, true, base::nullopt);
1482 cc::FrameSinkId(1, 1), base::nullopt);
1483 EXPECT_EQ( 1481 EXPECT_EQ(
1484 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); 1482 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
1485 1483
1486 // Make sure all the properties took. 1484 // Make sure all the properties took.
1487 EXPECT_TRUE(IsWindowHostVisible(top_level)); 1485 EXPECT_TRUE(IsWindowHostVisible(top_level));
1488 EXPECT_TRUE(top_level->TargetVisibility()); 1486 EXPECT_TRUE(top_level->TargetVisibility());
1489 EXPECT_EQ(display_id, window_tree_host.display_id()); 1487 EXPECT_EQ(display_id, window_tree_host.display_id());
1490 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 1488 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
1491 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); 1489 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
1492 } 1490 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 const uint8_t server_test_property2_value = 4; 1523 const uint8_t server_test_property2_value = 4;
1526 data->properties[kTestPropertyServerKey2] = 1524 data->properties[kTestPropertyServerKey2] =
1527 ConvertToPropertyTransportValue(server_test_property2_value); 1525 ConvertToPropertyTransportValue(server_test_property2_value);
1528 const int64_t display_id = 1; 1526 const int64_t display_id = 1;
1529 // Get the id of the in flight change for creating the new top_level. 1527 // Get the id of the in flight change for creating the new top_level.
1530 uint32_t new_window_in_flight_change_id; 1528 uint32_t new_window_in_flight_change_id;
1531 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1529 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1532 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); 1530 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id));
1533 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, 1531 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id,
1534 std::move(data), display_id, true, 1532 std::move(data), display_id, true,
1535 cc::FrameSinkId(1, 1), base::nullopt); 1533 base::nullopt);
1536 1534
1537 // The only value that should take effect is the property for 'yy' as it was 1535 // The only value that should take effect is the property for 'yy' as it was
1538 // not in flight. 1536 // not in flight.
1539 EXPECT_FALSE(top_level->TargetVisibility()); 1537 EXPECT_FALSE(top_level->TargetVisibility());
1540 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels()); 1538 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels());
1541 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); 1539 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds());
1542 EXPECT_EQ(explicitly_set_test_property1_value, 1540 EXPECT_EQ(explicitly_set_test_property1_value,
1543 top_level->GetProperty(kTestPropertyKey1)); 1541 top_level->GetProperty(kTestPropertyKey1));
1544 EXPECT_EQ(server_test_property2_value, 1542 EXPECT_EQ(server_test_property2_value,
1545 top_level->GetProperty(kTestPropertyKey2)); 1543 top_level->GetProperty(kTestPropertyKey2));
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 window_tree_host.reset(); 1747 window_tree_host.reset();
1750 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 1748 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
1751 1749
1752 // Get the id of the in flight change for creating the new window. 1750 // Get the id of the in flight change for creating the new window.
1753 uint32_t change_id; 1751 uint32_t change_id;
1754 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 1752 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
1755 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1753 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1756 1754
1757 const int64_t display_id = 1; 1755 const int64_t display_id = 1;
1758 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1756 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
1759 display_id, true, 1757 display_id, true, base::nullopt);
1760 cc::FrameSinkId(1, 1), base::nullopt);
1761 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 1758 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
1762 } 1759 }
1763 1760
1764 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) { 1761 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
1765 RegisterTestProperties(GetPropertyConverter()); 1762 RegisterTestProperties(GetPropertyConverter());
1766 const uint8_t property_value = 11; 1763 const uint8_t property_value = 11;
1767 std::map<std::string, std::vector<uint8_t>> properties; 1764 std::map<std::string, std::vector<uint8_t>> properties;
1768 properties[kTestPropertyServerKey1] = 1765 properties[kTestPropertyServerKey1] =
1769 ConvertToPropertyTransportValue(property_value); 1766 ConvertToPropertyTransportValue(property_value);
1770 const char kUnknownPropertyKey[] = "unknown-property"; 1767 const char kUnknownPropertyKey[] = "unknown-property";
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 uint32_t change_id; 2053 uint32_t change_id;
2057 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 2054 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
2058 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 2055 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
2059 EXPECT_EQ(window_tree()->window_id(), server_id(top_level)); 2056 EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
2060 2057
2061 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 2058 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
2062 data->window_id = server_id(top_level); 2059 data->window_id = server_id(top_level);
2063 data->visible = true; 2060 data->visible = true;
2064 const int64_t display_id = 1; 2061 const int64_t display_id = 1;
2065 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 2062 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
2066 display_id, true, 2063 display_id, true, base::nullopt);
2067 cc::FrameSinkId(1, 1), base::nullopt);
2068 EXPECT_EQ( 2064 EXPECT_EQ(
2069 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); 2065 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
2070 EXPECT_TRUE(top_level->TargetVisibility()); 2066 EXPECT_TRUE(top_level->TargetVisibility());
2071 2067
2072 std::unique_ptr<CaptureRecorder> capture_recorder1( 2068 std::unique_ptr<CaptureRecorder> capture_recorder1(
2073 base::MakeUnique<CaptureRecorder>(root_window())); 2069 base::MakeUnique<CaptureRecorder>(root_window()));
2074 std::unique_ptr<CaptureRecorder> capture_recorder2( 2070 std::unique_ptr<CaptureRecorder> capture_recorder2(
2075 base::MakeUnique<CaptureRecorder>(top_level)); 2071 base::MakeUnique<CaptureRecorder>(top_level));
2076 EXPECT_NE(client::GetCaptureClient(root_window()), 2072 EXPECT_NE(client::GetCaptureClient(root_window()),
2077 client::GetCaptureClient(top_level)); 2073 client::GetCaptureClient(top_level));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 window_tree_host.InitHost(); 2282 window_tree_host.InitHost();
2287 2283
2288 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 2284 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
2289 data->window_id = server_id(top_level); 2285 data->window_id = server_id(top_level);
2290 data->bounds.SetRect(2, 4, 6, 8); 2286 data->bounds.SetRect(2, 4, 6, 8);
2291 const int64_t display_id = 10; 2287 const int64_t display_id = 10;
2292 uint32_t change_id; 2288 uint32_t change_id;
2293 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 2289 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
2294 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 2290 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
2295 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 2291 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
2296 display_id, true, 2292 display_id, true, base::nullopt);
2297 cc::FrameSinkId(1, 1), base::nullopt);
2298 2293
2299 // aura::Window should operate in DIP and aura::WindowTreeHost should operate 2294 // aura::Window should operate in DIP and aura::WindowTreeHost should operate
2300 // in pixels. 2295 // in pixels.
2301 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 2296 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
2302 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); 2297 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels());
2303 } 2298 }
2304 2299
2305 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) { 2300 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) {
2306 display::Screen* screen = display::Screen::GetScreen(); 2301 display::Screen* screen = display::Screen::GetScreen();
2307 const display::Display primary_display = screen->GetPrimaryDisplay(); 2302 const display::Display primary_display = screen->GetPrimaryDisplay();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 window_tree()->GetEventResult(event_id)); 2399 window_tree()->GetEventResult(event_id));
2405 EXPECT_TRUE(window_delegate1.got_move()); 2400 EXPECT_TRUE(window_delegate1.got_move());
2406 EXPECT_FALSE(window_delegate2.got_move()); 2401 EXPECT_FALSE(window_delegate2.got_move());
2407 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, 2402 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20,
2408 event_location_in_dip.y() + 30); 2403 event_location_in_dip.y() + 30);
2409 EXPECT_EQ(transformed_event_location_in_dip, 2404 EXPECT_EQ(transformed_event_location_in_dip,
2410 window_delegate1.last_event_location()); 2405 window_delegate1.last_event_location());
2411 } 2406 }
2412 2407
2413 } // namespace aura 2408 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/mus/window_tree_host_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698