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

Side by Side Diff: services/ui/ws/window_tree_client_unittest.cc

Issue 2414683003: Mus+Ash: propagate Surface ID to parents (Closed)
Patch Set: Don't follow null surface_info Created 4 years, 2 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 | « services/ui/ws/window_tree.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void OnWindowPredefinedCursorChanged(uint32_t window_id, 370 void OnWindowPredefinedCursorChanged(uint32_t window_id,
371 mojom::Cursor cursor_id) override { 371 mojom::Cursor cursor_id) override {
372 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id); 372 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id);
373 } 373 }
374 374
375 void OnDragDropStart( 375 void OnDragDropStart(
376 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data) override { 376 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data) override {
377 NOTIMPLEMENTED(); 377 NOTIMPLEMENTED();
378 } 378 }
379 379
380 void OnWindowSurfaceChanged(Id window_id,
381 const cc::SurfaceId& surface_id,
382 const cc::SurfaceSequence& surface_sequence,
383 const gfx::Size& frame_size,
384 float device_scale_factor) override {
385 tracker_.OnWindowSurfaceChanged(window_id, surface_id, surface_sequence,
386 frame_size, device_scale_factor);
387 }
388
380 void OnDragEnter(uint32_t window, 389 void OnDragEnter(uint32_t window,
381 uint32_t key_state, 390 uint32_t key_state,
382 const gfx::Point& position, 391 const gfx::Point& position,
383 uint32_t effect_bitmask, 392 uint32_t effect_bitmask,
384 const OnDragEnterCallback& callback) override { 393 const OnDragEnterCallback& callback) override {
385 NOTIMPLEMENTED(); 394 NOTIMPLEMENTED();
386 } 395 }
387 void OnDragOver(uint32_t window, 396 void OnDragOver(uint32_t window,
388 uint32_t key_state, 397 uint32_t key_state,
389 const gfx::Point& position, 398 const gfx::Point& position,
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 SingleChangeToDescription(*changes1())); 2114 SingleChangeToDescription(*changes1()));
2106 2115
2107 changes1()->clear(); 2116 changes1()->clear();
2108 // Explicitly releasing capture should not notify of lost capture. 2117 // Explicitly releasing capture should not notify of lost capture.
2109 wt1()->ReleaseCapture(3, window_1_2); 2118 wt1()->ReleaseCapture(3, window_1_2);
2110 wt_client1_->WaitForAllMessages(); 2119 wt_client1_->WaitForAllMessages();
2111 2120
2112 EXPECT_TRUE(changes1()->empty()); 2121 EXPECT_TRUE(changes1()->empty());
2113 } 2122 }
2114 2123
2124 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) {
2125 const Id window_1_100 = wt_client1()->NewWindow(100);
2126 ASSERT_TRUE(window_1_100);
2127 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100));
2128
2129 // Establish the second client at 1,100.
2130 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100));
2131
2132 // 1,100 is the id in the wt_client1's id space. The new client should see
2133 // 2,1 (the server id).
2134 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1);
2135 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id());
2136
2137 // The first window created in the second client gets a server id of 2,1
2138 // regardless of the id the client uses.
2139 const Id window_2_101 = wt_client2()->NewWindow(101);
2140 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101));
2141 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1);
2142 wt_client1()->WaitForChangeCount(1);
2143 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) +
2144 " old_parent=null new_parent=" + IdToString(window_1_100),
2145 SingleChangeToDescription(*changes1()));
2146 changes1()->clear();
2147
2148 // Submit a CompositorFrame to window_2_101 and make sure server gets it.
2149 mojom::SurfacePtr surface_ptr;
2150 mojom::SurfaceClientRequest client_request;
2151 mojom::SurfaceClientPtr surface_client_ptr;
2152 client_request = mojo::GetProxy(&surface_client_ptr);
2153 wt2()->AttachSurface(window_2_101, mojom::SurfaceType::DEFAULT,
2154 mojo::GetProxy(&surface_ptr),
2155 std::move(surface_client_ptr));
2156 cc::CompositorFrame compositor_frame;
2157 compositor_frame.delegated_frame_data =
2158 base::MakeUnique<cc::DelegatedFrameData>();
2159 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
2160 gfx::Rect frame_rect(0, 0, 100, 100);
2161 render_pass->SetNew(cc::RenderPassId(1, 1), frame_rect, frame_rect,
2162 gfx::Transform());
2163 compositor_frame.delegated_frame_data->render_pass_list.push_back(
2164 std::move(render_pass));
2165 surface_ptr->SubmitCompositorFrame(std::move(compositor_frame),
2166 base::Closure());
2167 // Make sure the parent connection gets the surface ID.
2168 wt_client1()->WaitForChangeCount(1);
2169 // Verify that the submitted frame is for |window_2_101|.
2170 EXPECT_EQ(window_2_101_in_ws1,
2171 changes1()->back().surface_id.frame_sink_id().client_id());
2172 }
2173
2115 // TODO(sky): need to better track changes to initial client. For example, 2174 // TODO(sky): need to better track changes to initial client. For example,
2116 // that SetBounsdWindows/AddWindow and the like don't result in messages to the 2175 // that SetBounsdWindows/AddWindow and the like don't result in messages to the
2117 // originating client. 2176 // originating client.
2118 2177
2119 // TODO(sky): make sure coverage of what was 2178 // TODO(sky): make sure coverage of what was
2120 // WindowManagerTest.SecondEmbedRoot_InitService and 2179 // WindowManagerTest.SecondEmbedRoot_InitService and
2121 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2180 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2122 // manager 2181 // manager
2123 // tests. 2182 // tests.
2124 2183
2125 } // namespace test 2184 } // namespace test
2126 } // namespace ws 2185 } // namespace ws
2127 } // namespace ui 2186 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698