| 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 "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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); | 465 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); |
| 466 }; | 466 }; |
| 467 | 467 |
| 468 } // namespace | 468 } // namespace |
| 469 | 469 |
| 470 TEST_F(WindowTreeClientClientTest, InputEventBasic) { | 470 TEST_F(WindowTreeClientClientTest, InputEventBasic) { |
| 471 InputEventBasicTestWindowDelegate window_delegate(window_tree()); | 471 InputEventBasicTestWindowDelegate window_delegate(window_tree()); |
| 472 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 472 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 473 Window* top_level = window_tree_host.window(); | 473 Window* top_level = window_tree_host.window(); |
| 474 const gfx::Rect bounds(0, 0, 100, 100); | 474 const gfx::Rect bounds(0, 0, 100, 100); |
| 475 window_tree_host.SetBounds(bounds); | 475 window_tree_host.SetBoundsInPixels(bounds); |
| 476 window_tree_host.Show(); | 476 window_tree_host.Show(); |
| 477 EXPECT_EQ(bounds, top_level->bounds()); | 477 EXPECT_EQ(bounds, top_level->bounds()); |
| 478 EXPECT_EQ(bounds, window_tree_host.GetBounds()); | 478 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
| 479 Window child(&window_delegate); | 479 Window child(&window_delegate); |
| 480 child.Init(ui::LAYER_NOT_DRAWN); | 480 child.Init(ui::LAYER_NOT_DRAWN); |
| 481 top_level->AddChild(&child); | 481 top_level->AddChild(&child); |
| 482 child.SetBounds(gfx::Rect(0, 0, 100, 100)); | 482 child.SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 483 child.Show(); | 483 child.Show(); |
| 484 EXPECT_FALSE(window_delegate.got_move()); | 484 EXPECT_FALSE(window_delegate.got_move()); |
| 485 EXPECT_FALSE(window_delegate.was_acked()); | 485 EXPECT_FALSE(window_delegate.was_acked()); |
| 486 std::unique_ptr<ui::Event> ui_event( | 486 std::unique_ptr<ui::Event> ui_event( |
| 487 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 487 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 488 ui::EventTimeForNow(), ui::EF_NONE, 0)); | 488 ui::EventTimeForNow(), ui::EF_NONE, 0)); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 display_id, true); | 762 display_id, true); |
| 763 EXPECT_EQ( | 763 EXPECT_EQ( |
| 764 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); | 764 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); |
| 765 | 765 |
| 766 // Make sure all the properties took. | 766 // Make sure all the properties took. |
| 767 EXPECT_TRUE(IsWindowHostVisible(top_level)); | 767 EXPECT_TRUE(IsWindowHostVisible(top_level)); |
| 768 EXPECT_TRUE(top_level->TargetVisibility()); | 768 EXPECT_TRUE(top_level->TargetVisibility()); |
| 769 // TODO: check display_id. | 769 // TODO: check display_id. |
| 770 EXPECT_EQ(display_id, window_tree_host.display_id()); | 770 EXPECT_EQ(display_id, window_tree_host.display_id()); |
| 771 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 771 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
| 772 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBounds()); | 772 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels()); |
| 773 } | 773 } |
| 774 | 774 |
| 775 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { | 775 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { |
| 776 RegisterTestProperties(GetPropertyConverter()); | 776 RegisterTestProperties(GetPropertyConverter()); |
| 777 | 777 |
| 778 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | 778 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 779 Window* top_level = window_tree_host.window(); | 779 Window* top_level = window_tree_host.window(); |
| 780 | 780 |
| 781 EXPECT_FALSE(top_level->TargetVisibility()); | 781 EXPECT_FALSE(top_level->TargetVisibility()); |
| 782 | 782 |
| 783 // Make visibility go from false->true->false. Don't ack immediately. | 783 // Make visibility go from false->true->false. Don't ack immediately. |
| 784 top_level->Show(); | 784 top_level->Show(); |
| 785 top_level->Hide(); | 785 top_level->Hide(); |
| 786 | 786 |
| 787 // Change bounds to 5, 6, 7, 8. | 787 // Change bounds to 5, 6, 7, 8. |
| 788 window_tree_host.SetBounds(gfx::Rect(5, 6, 7, 8)); | 788 window_tree_host.SetBoundsInPixels(gfx::Rect(5, 6, 7, 8)); |
| 789 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds()); | 789 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds()); |
| 790 | 790 |
| 791 const uint8_t explicitly_set_test_property1_value = 2; | 791 const uint8_t explicitly_set_test_property1_value = 2; |
| 792 top_level->SetProperty(kTestPropertyKey1, | 792 top_level->SetProperty(kTestPropertyKey1, |
| 793 explicitly_set_test_property1_value); | 793 explicitly_set_test_property1_value); |
| 794 | 794 |
| 795 // Ack the new window top level top_level Vis and bounds shouldn't change. | 795 // Ack the new window top level top_level Vis and bounds shouldn't change. |
| 796 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 796 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| 797 data->window_id = server_id(top_level); | 797 data->window_id = server_id(top_level); |
| 798 const gfx::Rect bounds_from_server(1, 2, 3, 4); | 798 const gfx::Rect bounds_from_server(1, 2, 3, 4); |
| 799 data->bounds = bounds_from_server; | 799 data->bounds = bounds_from_server; |
| 800 data->visible = true; | 800 data->visible = true; |
| 801 const uint8_t server_test_property1_value = 3; | 801 const uint8_t server_test_property1_value = 3; |
| 802 data->properties[kTestPropertyServerKey1] = | 802 data->properties[kTestPropertyServerKey1] = |
| 803 ConvertToPropertyTransportValue(server_test_property1_value); | 803 ConvertToPropertyTransportValue(server_test_property1_value); |
| 804 const uint8_t server_test_property2_value = 4; | 804 const uint8_t server_test_property2_value = 4; |
| 805 data->properties[kTestPropertyServerKey2] = | 805 data->properties[kTestPropertyServerKey2] = |
| 806 ConvertToPropertyTransportValue(server_test_property2_value); | 806 ConvertToPropertyTransportValue(server_test_property2_value); |
| 807 const int64_t display_id = 1; | 807 const int64_t display_id = 1; |
| 808 // Get the id of the in flight change for creating the new top_level. | 808 // Get the id of the in flight change for creating the new top_level. |
| 809 uint32_t new_window_in_flight_change_id; | 809 uint32_t new_window_in_flight_change_id; |
| 810 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( | 810 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( |
| 811 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); | 811 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); |
| 812 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, | 812 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, |
| 813 std::move(data), display_id, true); | 813 std::move(data), display_id, true); |
| 814 | 814 |
| 815 // The only value that should take effect is the property for 'yy' as it was | 815 // The only value that should take effect is the property for 'yy' as it was |
| 816 // not in flight. | 816 // not in flight. |
| 817 EXPECT_FALSE(top_level->TargetVisibility()); | 817 EXPECT_FALSE(top_level->TargetVisibility()); |
| 818 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBounds()); | 818 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels()); |
| 819 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); | 819 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); |
| 820 EXPECT_EQ(explicitly_set_test_property1_value, | 820 EXPECT_EQ(explicitly_set_test_property1_value, |
| 821 top_level->GetProperty(kTestPropertyKey1)); | 821 top_level->GetProperty(kTestPropertyKey1)); |
| 822 EXPECT_EQ(server_test_property2_value, | 822 EXPECT_EQ(server_test_property2_value, |
| 823 top_level->GetProperty(kTestPropertyKey2)); | 823 top_level->GetProperty(kTestPropertyKey2)); |
| 824 | 824 |
| 825 // Tell the client the changes failed. This should cause the values to change | 825 // Tell the client the changes failed. This should cause the values to change |
| 826 // to that of the server. | 826 // to that of the server. |
| 827 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE, | 827 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE, |
| 828 false)); | 828 false)); |
| 829 EXPECT_FALSE(top_level->TargetVisibility()); | 829 EXPECT_FALSE(top_level->TargetVisibility()); |
| 830 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( | 830 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
| 831 WindowTreeChangeType::VISIBLE, false)); | 831 WindowTreeChangeType::VISIBLE, false)); |
| 832 EXPECT_TRUE(top_level->TargetVisibility()); | 832 EXPECT_TRUE(top_level->TargetVisibility()); |
| 833 window_tree()->AckAllChangesOfType(WindowTreeChangeType::BOUNDS, false); | 833 window_tree()->AckAllChangesOfType(WindowTreeChangeType::BOUNDS, false); |
| 834 // The bounds of the top_level is always at the origin. | 834 // The bounds of the top_level is always at the origin. |
| 835 EXPECT_EQ(gfx::Rect(bounds_from_server.size()), top_level->bounds()); | 835 EXPECT_EQ(gfx::Rect(bounds_from_server.size()), top_level->bounds()); |
| 836 // But the bounds of the WindowTreeHost is display relative. | 836 // But the bounds of the WindowTreeHost is display relative. |
| 837 EXPECT_EQ(bounds_from_server, | 837 EXPECT_EQ(bounds_from_server, |
| 838 top_level->GetRootWindow()->GetHost()->GetBounds()); | 838 top_level->GetRootWindow()->GetHost()->GetBoundsInPixels()); |
| 839 window_tree()->AckAllChangesOfType(WindowTreeChangeType::PROPERTY, false); | 839 window_tree()->AckAllChangesOfType(WindowTreeChangeType::PROPERTY, false); |
| 840 EXPECT_EQ(server_test_property1_value, | 840 EXPECT_EQ(server_test_property1_value, |
| 841 top_level->GetProperty(kTestPropertyKey1)); | 841 top_level->GetProperty(kTestPropertyKey1)); |
| 842 EXPECT_EQ(server_test_property2_value, | 842 EXPECT_EQ(server_test_property2_value, |
| 843 top_level->GetProperty(kTestPropertyKey2)); | 843 top_level->GetProperty(kTestPropertyKey2)); |
| 844 } | 844 } |
| 845 | 845 |
| 846 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) { | 846 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) { |
| 847 RegisterTestProperties(GetPropertyConverter()); | 847 RegisterTestProperties(GetPropertyConverter()); |
| 848 Window window(nullptr); | 848 Window window(nullptr); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 window1.Init(ui::LAYER_NOT_DRAWN); | 1335 window1.Init(ui::LAYER_NOT_DRAWN); |
| 1336 Window* window2 = new Window(nullptr); | 1336 Window* window2 = new Window(nullptr); |
| 1337 window2->Init(ui::LAYER_NOT_DRAWN); | 1337 window2->Init(ui::LAYER_NOT_DRAWN); |
| 1338 window1.AddChild(window2); | 1338 window1.AddChild(window2); |
| 1339 window_tree()->AckAllChanges(); | 1339 window_tree()->AckAllChanges(); |
| 1340 window_tree_client()->OnWindowDeleted(server_id(window2)); | 1340 window_tree_client()->OnWindowDeleted(server_id(window2)); |
| 1341 EXPECT_FALSE(window_tree()->has_change()); | 1341 EXPECT_FALSE(window_tree()->has_change()); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 } // namespace aura | 1344 } // namespace aura |
| OLD | NEW |