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

Side by Side Diff: ash/magnifier/magnification_controller_unittest.cc

Issue 1564973002: Don't center screen magnification on empty focus rectangle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test Created 4 years, 11 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 | « ash/magnifier/magnification_controller.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ash/magnifier/magnification_controller.h" 5 #include "ash/magnifier/magnification_controller.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 generator.MoveMouseToInHost(gfx::Point(400, 300)); 259 generator.MoveMouseToInHost(gfx::Point(400, 300));
260 EXPECT_EQ("400,300", CurrentPointOfInterest()); 260 EXPECT_EQ("400,300", CurrentPointOfInterest());
261 261
262 GetMagnificationController()->SetEnabled(true); 262 GetMagnificationController()->SetEnabled(true);
263 EXPECT_EQ("400,300", CurrentPointOfInterest()); 263 EXPECT_EQ("400,300", CurrentPointOfInterest());
264 264
265 generator.MoveMouseToInHost(gfx::Point(500, 400)); 265 generator.MoveMouseToInHost(gfx::Point(500, 400));
266 EXPECT_EQ("450,350", CurrentPointOfInterest()); 266 EXPECT_EQ("450,350", CurrentPointOfInterest());
267 } 267 }
268 268
269 TEST_F(MagnificationControllerTest, FollowFocusChanged) {
270 // Enables magnifier and confirm the viewport is at center.
271 GetMagnificationController()->SetEnabled(true);
272 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale());
273 EXPECT_EQ("200,150 400x300", GetViewport().ToString());
274
275 // Don't move viewport when focusing edit box.
276 GetMagnificationController()->HandleFocusedNodeChanged(
277 true, gfx::Rect(0, 0, 10, 10));
278 EXPECT_EQ("200,150 400x300", GetViewport().ToString());
279
280 // Move viewport to element in upper left.
281 GetMagnificationController()->HandleFocusedNodeChanged(
282 false, gfx::Rect(0, 0, 10, 10));
283 EXPECT_EQ("0,0 400x300", GetViewport().ToString());
284
285 // Move viewport to element in lower right.
286 GetMagnificationController()->HandleFocusedNodeChanged(
287 false, gfx::Rect(790, 590, 10, 10));
288 EXPECT_EQ("400,300 400x300", GetViewport().ToString());
289
290 // Don't follow focus onto empty rectangle.
291 GetMagnificationController()->HandleFocusedNodeChanged(
292 false, gfx::Rect(0, 0, 0, 0));
293 EXPECT_EQ("400,300 400x300", GetViewport().ToString());
294 }
295
269 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { 296 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) {
270 const aura::Env* env = aura::Env::GetInstance(); 297 const aura::Env* env = aura::Env::GetInstance();
271 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 298 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
272 299
273 generator.MoveMouseToInHost(gfx::Point(0, 0)); 300 generator.MoveMouseToInHost(gfx::Point(0, 0));
274 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); 301 EXPECT_EQ(1.f, GetMagnificationController()->GetScale());
275 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); 302 EXPECT_EQ("0,0 800x600", GetViewport().ToString());
276 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); 303 EXPECT_EQ("0,0", env->last_mouse_location().ToString());
277 304
278 // Enables magnifier and confirm the viewport is at center. 305 // Enables magnifier and confirm the viewport is at center.
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 UpdateDisplay("500x500"); 720 UpdateDisplay("500x500");
694 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); 721 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString());
695 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); 722 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale());
696 723
697 GetMagnificationController()->SetEnabled(false); 724 GetMagnificationController()->SetEnabled(false);
698 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); 725 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString());
699 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); 726 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale());
700 } 727 }
701 728
702 } // namespace ash 729 } // namespace ash
OLDNEW
« no previous file with comments | « ash/magnifier/magnification_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698