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

Side by Side Diff: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc

Issue 2019013002: mus: Send display-id to client only for the root windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: doc Created 4 years, 6 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
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 "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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root1) > 0u); 726 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root1) > 0u);
727 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root2) > 0u); 727 EXPECT_TRUE(setup.window_tree_connection()->GetRoots().count(root2) > 0u);
728 728
729 // Ack the request to the windowtree to create the new window. 729 // Ack the request to the windowtree to create the new window.
730 uint32_t change_id; 730 uint32_t change_id;
731 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); 731 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id));
732 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2)); 732 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2));
733 733
734 mojom::WindowDataPtr data = mojom::WindowData::New(); 734 mojom::WindowDataPtr data = mojom::WindowData::New();
735 data->window_id = server_id(root2); 735 data->window_id = server_id(root2);
736 data->display_id = 1; 736 const int64_t display_id = 1;
737 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 737 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
738 false); 738 display_id, false);
739 739
740 EXPECT_FALSE(WindowPrivate(root2).parent_drawn()); 740 EXPECT_FALSE(WindowPrivate(root2).parent_drawn());
741 741
742 // Should not be able to add a top level as a child of another window. 742 // Should not be able to add a top level as a child of another window.
743 root1->AddChild(root2); 743 root1->AddChild(root2);
744 ASSERT_EQ(nullptr, root2->parent()); 744 ASSERT_EQ(nullptr, root2->parent());
745 745
746 // Destroy the first root, shouldn't initiate tear down. 746 // Destroy the first root, shouldn't initiate tear down.
747 root1->Destroy(); 747 root1->Destroy();
748 root1 = nullptr; 748 root1 = nullptr;
(...skipping 11 matching lines...) Expand all
760 EXPECT_FALSE(root2->IsDrawn()); 760 EXPECT_FALSE(root2->IsDrawn());
761 EXPECT_FALSE(root2->visible()); 761 EXPECT_FALSE(root2->visible());
762 762
763 // Ack the request to the windowtree to create the new window. 763 // Ack the request to the windowtree to create the new window.
764 uint32_t change_id; 764 uint32_t change_id;
765 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); 765 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id));
766 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2)); 766 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2));
767 767
768 mojom::WindowDataPtr data = mojom::WindowData::New(); 768 mojom::WindowDataPtr data = mojom::WindowData::New();
769 data->window_id = server_id(root2); 769 data->window_id = server_id(root2);
770 data->display_id = 1;
771 data->bounds = mojo::Rect::From(gfx::Rect(1, 2, 3, 4)); 770 data->bounds = mojo::Rect::From(gfx::Rect(1, 2, 3, 4));
772 data->visible = true; 771 data->visible = true;
772 const int64_t display_id = 1;
773 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 773 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
774 true); 774 display_id, true);
775 775
776 // Make sure all the properties took. 776 // Make sure all the properties took.
777 EXPECT_TRUE(root2->IsDrawn()); 777 EXPECT_TRUE(root2->IsDrawn());
778 EXPECT_TRUE(root2->visible()); 778 EXPECT_TRUE(root2->visible());
779 EXPECT_EQ(1, root2->display_id()); 779 EXPECT_EQ(1, root2->display_id());
780 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), root2->bounds()); 780 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), root2->bounds());
781 } 781 }
782 782
783 TEST_F(WindowTreeClientImplTest, NewTopLevelWindowGetsAllChangesInFlight) { 783 TEST_F(WindowTreeClientImplTest, NewTopLevelWindowGetsAllChangesInFlight) {
784 WindowTreeSetup setup; 784 WindowTreeSetup setup;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 root2->SetSharedProperty<std::string>("xx", "client_xx"); 818 root2->SetSharedProperty<std::string>("xx", "client_xx");
819 uint32_t property_in_flight_change_id; 819 uint32_t property_in_flight_change_id;
820 ASSERT_TRUE( 820 ASSERT_TRUE(
821 setup.window_tree()->GetAndClearChangeId(&property_in_flight_change_id)); 821 setup.window_tree()->GetAndClearChangeId(&property_in_flight_change_id));
822 EXPECT_NE(bounds_in_flight_change_id, property_in_flight_change_id); 822 EXPECT_NE(bounds_in_flight_change_id, property_in_flight_change_id);
823 823
824 // Ack the new window top level window. Vis and bounds shouldn't change. 824 // Ack the new window top level window. Vis and bounds shouldn't change.
825 mojom::WindowDataPtr data = mojom::WindowData::New(); 825 mojom::WindowDataPtr data = mojom::WindowData::New();
826 data->window_id = server_id(root2); 826 data->window_id = server_id(root2);
827 data->bounds = mojo::Rect::From(gfx::Rect(1, 2, 3, 4)); 827 data->bounds = mojo::Rect::From(gfx::Rect(1, 2, 3, 4));
828 data->display_id = 1;
829 data->visible = true; 828 data->visible = true;
830 data->properties["xx"] = mojo::Array<uint8_t>::From(std::string("server_xx")); 829 data->properties["xx"] = mojo::Array<uint8_t>::From(std::string("server_xx"));
831 data->properties["yy"] = mojo::Array<uint8_t>::From(std::string("server_yy")); 830 data->properties["yy"] = mojo::Array<uint8_t>::From(std::string("server_yy"));
832 setup.window_tree_client()->OnTopLevelCreated(new_window_in_flight_change_id, 831 const int64_t display_id = 1;
833 std::move(data), true); 832 setup.window_tree_client()->OnTopLevelCreated(
833 new_window_in_flight_change_id, 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_TRUE(WindowPrivate(root2).parent_drawn()); 837 EXPECT_TRUE(WindowPrivate(root2).parent_drawn());
838 EXPECT_FALSE(root2->visible()); 838 EXPECT_FALSE(root2->visible());
839 EXPECT_EQ(1, root2->display_id()); 839 EXPECT_EQ(1, root2->display_id());
840 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), root2->bounds()); 840 EXPECT_EQ(gfx::Rect(5, 6, 7, 8), root2->bounds());
841 EXPECT_EQ(2u, root2->shared_properties().size()); 841 EXPECT_EQ(2u, root2->shared_properties().size());
842 ASSERT_TRUE(root2->HasSharedProperty("yy")); 842 ASSERT_TRUE(root2->HasSharedProperty("yy"));
843 EXPECT_EQ("server_yy", root2->GetSharedProperty<std::string>("yy")); 843 EXPECT_EQ("server_yy", root2->GetSharedProperty<std::string>("yy"));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 ASSERT_TRUE(root2); 889 ASSERT_TRUE(root2);
890 ASSERT_EQ(2u, setup.window_tree_connection()->GetRoots().size()); 890 ASSERT_EQ(2u, setup.window_tree_connection()->GetRoots().size());
891 891
892 // Get the id of the in flight change for creating the new window. 892 // Get the id of the in flight change for creating the new window.
893 uint32_t change_id; 893 uint32_t change_id;
894 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id)); 894 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id));
895 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2)); 895 EXPECT_EQ(setup.window_tree()->window_id(), server_id(root2));
896 896
897 mojom::WindowDataPtr data = mojom::WindowData::New(); 897 mojom::WindowDataPtr data = mojom::WindowData::New();
898 data->window_id = server_id(root2); 898 data->window_id = server_id(root2);
899 data->display_id = 1;
900 899
901 // Destroy the window before the server has a chance to ack the window 900 // Destroy the window before the server has a chance to ack the window
902 // creation. 901 // creation.
903 root2->Destroy(); 902 root2->Destroy();
904 EXPECT_EQ(1u, setup.window_tree_connection()->GetRoots().size()); 903 EXPECT_EQ(1u, setup.window_tree_connection()->GetRoots().size());
905 904
905 const int64_t display_id = 1;
906 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 906 setup.window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
907 true); 907 display_id, true);
908 EXPECT_EQ(1u, setup.window_tree_connection()->GetRoots().size()); 908 EXPECT_EQ(1u, setup.window_tree_connection()->GetRoots().size());
909 } 909 }
910 910
911 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly 911 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
912 // updated on failures. 912 // updated on failures.
913 TEST_F(WindowTreeClientImplTest, ExplicitCapture) { 913 TEST_F(WindowTreeClientImplTest, ExplicitCapture) {
914 WindowTreeSetup setup; 914 WindowTreeSetup setup;
915 Window* root = setup.GetFirstRoot(); 915 Window* root = setup.GetFirstRoot();
916 ASSERT_TRUE(root); 916 ASSERT_TRUE(root);
917 917
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 1048
1049 // Create a new Window, and attempt to place capture on that. 1049 // Create a new Window, and attempt to place capture on that.
1050 Window* child = setup.window_tree_connection()->NewWindow(); 1050 Window* child = setup.window_tree_connection()->NewWindow();
1051 child->SetVisible(true); 1051 child->SetVisible(true);
1052 root->AddChild(child); 1052 root->AddChild(child);
1053 child->SetCapture(); 1053 child->SetCapture();
1054 EXPECT_TRUE(child->HasCapture()); 1054 EXPECT_TRUE(child->HasCapture());
1055 } 1055 }
1056 1056
1057 } // namespace mus 1057 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/tests/window_tree_client_impl_private.cc ('k') | components/mus/public/interfaces/window_tree.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698