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

Side by Side Diff: components/mus/ws/display_unittest.cc

Issue 1868783003: Makes SetFocus() notify callback correctly on failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « components/mus/ws/display.cc ('k') | components/mus/ws/focus_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 8
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ASSERT_TRUE(window_tree_client1); 252 ASSERT_TRUE(window_tree_client1);
253 WindowManagerFactoryRegistryTestApi( 253 WindowManagerFactoryRegistryTestApi(
254 window_server_->window_manager_factory_registry()) 254 window_server_->window_manager_factory_registry())
255 .AddService(kTestId2, &test_window_manager_factory_); 255 .AddService(kTestId2, &test_window_manager_factory_);
256 window_server_->user_id_tracker()->SetActiveUserId(kTestId1); 256 window_server_->user_id_tracker()->SetActiveUserId(kTestId1);
257 DisplayManager* display_manager = window_server_->display_manager(); 257 DisplayManager* display_manager = window_server_->display_manager();
258 ASSERT_EQ(1u, display_manager->displays().size()); 258 ASSERT_EQ(1u, display_manager->displays().size());
259 Display* display = *display_manager->displays().begin(); 259 Display* display = *display_manager->displays().begin();
260 WindowManagerState* wms_for_id2 = 260 WindowManagerState* wms_for_id2 =
261 display->GetWindowManagerStateForUser(kTestId2); 261 display->GetWindowManagerStateForUser(kTestId2);
262 wms_for_id2->tree()->AddActivationParent(
263 ClientWindowIdForFirstRoot(wms_for_id2->tree()));
262 ASSERT_TRUE(wms_for_id2); 264 ASSERT_TRUE(wms_for_id2);
263 EXPECT_FALSE(wms_for_id2->IsActive()); 265 EXPECT_FALSE(wms_for_id2->IsActive());
266 ClientWindowId child2_id;
267 NewWindowInTree(wms_for_id2->tree(), &child2_id);
264 268
265 // Focus should fail for windows in inactive window managers. 269 // Focus should fail for windows in inactive window managers.
266 EXPECT_FALSE(wms_for_id2->tree()->SetFocus( 270 EXPECT_FALSE(wms_for_id2->tree()->SetFocus(child2_id));
267 ClientWindowIdForFirstRoot(wms_for_id2->tree())));
268 271
269 // Focus should succeed for the active window manager. 272 // Focus should succeed for the active window manager.
270 WindowManagerState* wms_for_id1 = 273 WindowManagerState* wms_for_id1 =
271 display->GetWindowManagerStateForUser(kTestId1); 274 display->GetWindowManagerStateForUser(kTestId1);
272 ASSERT_TRUE(wms_for_id1); 275 ASSERT_TRUE(wms_for_id1);
276 wms_for_id1->tree()->AddActivationParent(
277 ClientWindowIdForFirstRoot(wms_for_id1->tree()));
278 ClientWindowId child1_id;
279 NewWindowInTree(wms_for_id1->tree(), &child1_id);
273 EXPECT_TRUE(wms_for_id1->IsActive()); 280 EXPECT_TRUE(wms_for_id1->IsActive());
274 EXPECT_TRUE(wms_for_id1->tree()->SetFocus( 281 EXPECT_TRUE(wms_for_id1->tree()->SetFocus(child1_id));
275 ClientWindowIdForFirstRoot(wms_for_id1->tree())));
276 } 282 }
277 283
278 // Verifies clients are notified of focus changes in different displays. 284 // Verifies clients are notified of focus changes in different displays.
279 TEST_F(DisplayTest, CrossDisplayFocus) { 285 TEST_F(DisplayTest, CrossDisplayFocus) {
280 window_server_delegate_.set_num_displays_to_create(2); 286 window_server_delegate_.set_num_displays_to_create(2);
281 const UserId kTestId1 = "20"; 287 const UserId kTestId1 = "20";
282 WindowManagerFactoryRegistryTestApi( 288 WindowManagerFactoryRegistryTestApi(
283 window_server_->window_manager_factory_registry()) 289 window_server_->window_manager_factory_registry())
284 .AddService(kTestId1, &test_window_manager_factory_); 290 .AddService(kTestId1, &test_window_manager_factory_);
285 window_server_->user_id_tracker()->SetActiveUserId(kTestId1); 291 window_server_->user_id_tracker()->SetActiveUserId(kTestId1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 EXPECT_TRUE(window_tree_binding2->client()->tracker()->changes()->empty()); 332 EXPECT_TRUE(window_tree_binding2->client()->tracker()->changes()->empty());
327 window_tree_binding1->client()->tracker()->changes()->clear(); 333 window_tree_binding1->client()->tracker()->changes()->clear();
328 window_tree_binding2->client()->tracker()->changes()->clear(); 334 window_tree_binding2->client()->tracker()->changes()->clear();
329 EXPECT_FALSE(display1->GetFocusedWindow()); 335 EXPECT_FALSE(display1->GetFocusedWindow());
330 EXPECT_EQ(child2, display2->GetFocusedWindow()); 336 EXPECT_EQ(child2, display2->GetFocusedWindow());
331 } 337 }
332 338
333 } // namespace test 339 } // namespace test
334 } // namespace ws 340 } // namespace ws
335 } // namespace mus 341 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/display.cc ('k') | components/mus/ws/focus_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698