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

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

Issue 2495423005: Enables passing initial properties to top level window creation (Closed)
Patch Set: cleanup Created 4 years, 1 month 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 uint32_t change_id; 897 uint32_t change_id;
898 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType( 898 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
899 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 899 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
900 900
901 const int64_t display_id = 1; 901 const int64_t display_id = 1;
902 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 902 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
903 display_id, true); 903 display_id, true);
904 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size()); 904 EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
905 } 905 }
906 906
907 TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
908 const uint8_t property_value = 11;
909 SetPropertyConverter(base::MakeUnique<TestPropertyConverter>());
910 std::map<std::string, std::vector<uint8_t>> properties;
911 properties[kTestPropertyServerKey1].resize(1);
912 properties[kTestPropertyServerKey1][0] = property_value;
913 std::unique_ptr<WindowTreeHostMus> window_tree_host =
914 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(),
915 &properties);
916 // Verify the property made it to the window.
917 EXPECT_EQ(property_value,
918 window_tree_host->window()->GetProperty(kTestPropertyKey1));
919
920 // Get the id of the in flight change for creating the new top level window.
921 uint32_t change_id;
922 ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
923 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
924
925 // Verify the property was sent to the server.
926 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties =
927 window_tree()->GetLastNewWindowProperties();
928 ASSERT_FALSE(transport_properties.is_null());
929 std::map<std::string, std::vector<uint8_t>> properties2 =
930 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
931 ASSERT_EQ(1u, properties2.count(kTestPropertyServerKey1));
932 ASSERT_EQ(1u, properties2[kTestPropertyServerKey1].size());
933 EXPECT_EQ(property_value, properties2[kTestPropertyServerKey1][0]);
934 }
935
907 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly 936 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
908 // updated on failures. 937 // updated on failures.
909 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { 938 TEST_F(WindowTreeClientWmTest, ExplicitCapture) {
910 root_window()->SetCapture(); 939 root_window()->SetCapture();
911 EXPECT_TRUE(root_window()->HasCapture()); 940 EXPECT_TRUE(root_window()->HasCapture());
912 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( 941 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
913 WindowTreeChangeType::CAPTURE, false)); 942 WindowTreeChangeType::CAPTURE, false));
914 EXPECT_FALSE(root_window()->HasCapture()); 943 EXPECT_FALSE(root_window()->HasCapture());
915 944
916 root_window()->SetCapture(); 945 root_window()->SetCapture();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 ASSERT_EQ(1u, root_window()->children().size()); 1188 ASSERT_EQ(1u, root_window()->children().size());
1160 Window* server_window = root_window()->children()[0]; 1189 Window* server_window = root_window()->children()[0];
1161 EXPECT_EQ(window1->parent(), server_window); 1190 EXPECT_EQ(window1->parent(), server_window);
1162 EXPECT_EQ(window2->parent(), server_window); 1191 EXPECT_EQ(window2->parent(), server_window);
1163 ASSERT_EQ(2u, server_window->children().size()); 1192 ASSERT_EQ(2u, server_window->children().size());
1164 EXPECT_EQ(window1, server_window->children()[0]); 1193 EXPECT_EQ(window1, server_window->children()[0]);
1165 EXPECT_EQ(window2, server_window->children()[1]); 1194 EXPECT_EQ(window2, server_window->children()[1]);
1166 } 1195 }
1167 1196
1168 } // namespace aura 1197 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698