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

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

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: Created 4 years 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 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); 485 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate);
486 }; 486 };
487 487
488 } // namespace 488 } // namespace
489 489
490 TEST_F(WindowTreeClientClientTest, InputEventBasic) { 490 TEST_F(WindowTreeClientClientTest, InputEventBasic) {
491 InputEventBasicTestWindowDelegate window_delegate(window_tree()); 491 InputEventBasicTestWindowDelegate window_delegate(window_tree());
492 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 492 WindowTreeHostMus window_tree_host(window_tree_client_impl());
493 Window* top_level = window_tree_host.window(); 493 Window* top_level = window_tree_host.window();
494 const gfx::Rect bounds(0, 0, 100, 100); 494 const gfx::Rect bounds(0, 0, 100, 100);
495 window_tree_host.SetBounds(bounds); 495 window_tree_host.SetBoundsInPixel(bounds);
496 window_tree_host.Show(); 496 window_tree_host.Show();
497 EXPECT_EQ(bounds, top_level->bounds()); 497 EXPECT_EQ(bounds, top_level->bounds());
498 EXPECT_EQ(bounds, window_tree_host.GetBounds()); 498 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixel());
499 Window child(&window_delegate); 499 Window child(&window_delegate);
500 child.Init(ui::LAYER_NOT_DRAWN); 500 child.Init(ui::LAYER_NOT_DRAWN);
501 top_level->AddChild(&child); 501 top_level->AddChild(&child);
502 child.SetBounds(gfx::Rect(0, 0, 100, 100)); 502 child.SetBounds(gfx::Rect(0, 0, 100, 100));
503 child.Show(); 503 child.Show();
504 EXPECT_FALSE(window_delegate.got_move()); 504 EXPECT_FALSE(window_delegate.got_move());
505 EXPECT_FALSE(window_delegate.was_acked()); 505 EXPECT_FALSE(window_delegate.was_acked());
506 std::unique_ptr<ui::Event> ui_event( 506 std::unique_ptr<ui::Event> ui_event(
507 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 507 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
508 ui::EventTimeForNow(), ui::EF_NONE, 0)); 508 ui::EventTimeForNow(), ui::EF_NONE, 0));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 display_id, true); 782 display_id, true);
783 EXPECT_EQ( 783 EXPECT_EQ(
784 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE)); 784 0u, window_tree()->GetChangeCountForType(WindowTreeChangeType::VISIBLE));
785 785
786 // Make sure all the properties took. 786 // Make sure all the properties took.
787 EXPECT_TRUE(IsWindowHostVisible(top_level)); 787 EXPECT_TRUE(IsWindowHostVisible(top_level));
788 EXPECT_TRUE(top_level->TargetVisibility()); 788 EXPECT_TRUE(top_level->TargetVisibility());
789 // TODO: check display_id. 789 // TODO: check display_id.
790 EXPECT_EQ(display_id, window_tree_host.display_id()); 790 EXPECT_EQ(display_id, window_tree_host.display_id());
791 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 791 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
792 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBounds()); 792 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixel());
793 } 793 }
794 794
795 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) { 795 TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
796 RegisterTestProperties(GetPropertyConverter()); 796 RegisterTestProperties(GetPropertyConverter());
797 797
798 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 798 WindowTreeHostMus window_tree_host(window_tree_client_impl());
799 Window* top_level = window_tree_host.window(); 799 Window* top_level = window_tree_host.window();
800 800
801 EXPECT_FALSE(top_level->TargetVisibility()); 801 EXPECT_FALSE(top_level->TargetVisibility());
802 802
803 // Make visibility go from false->true->false. Don't ack immediately. 803 // Make visibility go from false->true->false. Don't ack immediately.
804 top_level->Show(); 804 top_level->Show();
805 top_level->Hide(); 805 top_level->Hide();
806 806
807 // Change bounds to 5, 6, 7, 8. 807 // Change bounds to 5, 6, 7, 8.
808 window_tree_host.SetBounds(gfx::Rect(5, 6, 7, 8)); 808 window_tree_host.SetBoundsInPixel(gfx::Rect(5, 6, 7, 8));
809 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds()); 809 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds());
810 810
811 const uint8_t explicitly_set_test_property1_value = 2; 811 const uint8_t explicitly_set_test_property1_value = 2;
812 top_level->SetProperty(kTestPropertyKey1, 812 top_level->SetProperty(kTestPropertyKey1,
813 explicitly_set_test_property1_value); 813 explicitly_set_test_property1_value);
814 814
815 // Ack the new window top level top_level Vis and bounds shouldn't change. 815 // Ack the new window top level top_level Vis and bounds shouldn't change.
816 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 816 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
817 data->window_id = server_id(top_level); 817 data->window_id = server_id(top_level);
818 const gfx::Rect bounds_from_server(1, 2, 3, 4); 818 const gfx::Rect bounds_from_server(1, 2, 3, 4);
819 data->bounds = bounds_from_server; 819 data->bounds = bounds_from_server;
820 data->visible = true; 820 data->visible = true;
821 const uint8_t server_test_property1_value = 3; 821 const uint8_t server_test_property1_value = 3;
822 data->properties[kTestPropertyServerKey1] = 822 data->properties[kTestPropertyServerKey1] =
823 ConvertToPropertyTransportValue(server_test_property1_value); 823 ConvertToPropertyTransportValue(server_test_property1_value);
824 const uint8_t server_test_property2_value = 4; 824 const uint8_t server_test_property2_value = 4;
825 data->properties[kTestPropertyServerKey2] = 825 data->properties[kTestPropertyServerKey2] =
826 ConvertToPropertyTransportValue(server_test_property2_value); 826 ConvertToPropertyTransportValue(server_test_property2_value);
827 const int64_t display_id = 1; 827 const int64_t display_id = 1;
828 // Get the id of the in flight change for creating the new top_level. 828 // Get the id of the in flight change for creating the new top_level.
829 uint32_t new_window_in_flight_change_id; 829 uint32_t new_window_in_flight_change_id;
830 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 830 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
831 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id)); 831 WindowTreeChangeType::NEW_TOP_LEVEL, &new_window_in_flight_change_id));
832 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, 832 window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id,
833 std::move(data), display_id, true); 833 std::move(data), display_id, true);
834 834
835 // The only value that should take effect is the property for 'yy' as it was 835 // The only value that should take effect is the property for 'yy' as it was
836 // not in flight. 836 // not in flight.
837 EXPECT_FALSE(top_level->TargetVisibility()); 837 EXPECT_FALSE(top_level->TargetVisibility());
838 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBounds()); 838 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixel());
839 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds()); 839 EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds());
840 EXPECT_EQ(explicitly_set_test_property1_value, 840 EXPECT_EQ(explicitly_set_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 // Tell the client the changes failed. This should cause the values to change 845 // Tell the client the changes failed. This should cause the values to change
846 // to that of the server. 846 // to that of the server.
847 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE, 847 ASSERT_TRUE(window_tree()->AckFirstChangeOfType(WindowTreeChangeType::VISIBLE,
848 false)); 848 false));
849 EXPECT_FALSE(top_level->TargetVisibility()); 849 EXPECT_FALSE(top_level->TargetVisibility());
850 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 850 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
851 WindowTreeChangeType::VISIBLE, false)); 851 WindowTreeChangeType::VISIBLE, false));
852 EXPECT_TRUE(top_level->TargetVisibility()); 852 EXPECT_TRUE(top_level->TargetVisibility());
853 window_tree()->AckAllChangesOfType(WindowTreeChangeType::BOUNDS, false); 853 window_tree()->AckAllChangesOfType(WindowTreeChangeType::BOUNDS, false);
854 // The bounds of the top_level is always at the origin. 854 // The bounds of the top_level is always at the origin.
855 EXPECT_EQ(gfx::Rect(bounds_from_server.size()), top_level->bounds()); 855 EXPECT_EQ(gfx::Rect(bounds_from_server.size()), top_level->bounds());
856 // But the bounds of the WindowTreeHost is display relative. 856 // But the bounds of the WindowTreeHost is display relative.
857 EXPECT_EQ(bounds_from_server, 857 EXPECT_EQ(bounds_from_server,
858 top_level->GetRootWindow()->GetHost()->GetBounds()); 858 top_level->GetRootWindow()->GetHost()->GetBoundsInPixel());
859 window_tree()->AckAllChangesOfType(WindowTreeChangeType::PROPERTY, false); 859 window_tree()->AckAllChangesOfType(WindowTreeChangeType::PROPERTY, false);
860 EXPECT_EQ(server_test_property1_value, 860 EXPECT_EQ(server_test_property1_value,
861 top_level->GetProperty(kTestPropertyKey1)); 861 top_level->GetProperty(kTestPropertyKey1));
862 EXPECT_EQ(server_test_property2_value, 862 EXPECT_EQ(server_test_property2_value,
863 top_level->GetProperty(kTestPropertyKey2)); 863 top_level->GetProperty(kTestPropertyKey2));
864 } 864 }
865 865
866 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) { 866 TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) {
867 RegisterTestProperties(GetPropertyConverter()); 867 RegisterTestProperties(GetPropertyConverter());
868 Window window(nullptr); 868 Window window(nullptr);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 window1.Init(ui::LAYER_NOT_DRAWN); 1355 window1.Init(ui::LAYER_NOT_DRAWN);
1356 Window* window2 = new Window(nullptr); 1356 Window* window2 = new Window(nullptr);
1357 window2->Init(ui::LAYER_NOT_DRAWN); 1357 window2->Init(ui::LAYER_NOT_DRAWN);
1358 window1.AddChild(window2); 1358 window1.AddChild(window2);
1359 window_tree()->AckAllChanges(); 1359 window_tree()->AckAllChanges();
1360 window_tree_client()->OnWindowDeleted(server_id(window2)); 1360 window_tree_client()->OnWindowDeleted(server_id(window2));
1361 EXPECT_FALSE(window_tree()->has_change()); 1361 EXPECT_FALSE(window_tree()->has_change());
1362 } 1362 }
1363 1363
1364 } // namespace aura 1364 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698