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

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

Issue 2657283003: mash: make Env::last_mouse_location() accurate for Mus (Closed)
Patch Set: fix test Created 3 years, 10 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 | « no previous file | ui/aura/BUILD.gn » ('j') | ui/aura/env.h » ('J')
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/common/accessibility_types.h" 7 #include "ash/common/accessibility_types.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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 false, gfx::Rect(790, 590, 10, 10)); 272 false, gfx::Rect(790, 590, 10, 10));
273 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); 273 EXPECT_EQ("400,300 400x300", GetViewport().ToString());
274 274
275 // Don't follow focus onto empty rectangle. 275 // Don't follow focus onto empty rectangle.
276 GetMagnificationController()->HandleFocusedNodeChanged(false, 276 GetMagnificationController()->HandleFocusedNodeChanged(false,
277 gfx::Rect(0, 0, 0, 0)); 277 gfx::Rect(0, 0, 0, 0));
278 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); 278 EXPECT_EQ("400,300 400x300", GetViewport().ToString());
279 } 279 }
280 280
281 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { 281 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) {
282 const aura::Env* env = aura::Env::GetInstance(); 282 aura::Env* env = aura::Env::GetInstance();
283 283
284 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 0)); 284 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 0));
285 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); 285 EXPECT_EQ(1.f, GetMagnificationController()->GetScale());
286 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); 286 EXPECT_EQ("0,0 800x600", GetViewport().ToString());
287 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); 287 EXPECT_EQ("0,0", env->last_mouse_location().ToString());
288 288
289 // Enables magnifier and confirm the viewport is at center. 289 // Enables magnifier and confirm the viewport is at center.
290 GetMagnificationController()->SetEnabled(true); 290 GetMagnificationController()->SetEnabled(true);
291 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); 291 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale());
292 292
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 GetEventGenerator().MoveMouseToInHost(gfx::Point(780, 150)); 375 GetEventGenerator().MoveMouseToInHost(gfx::Point(780, 150));
376 EXPECT_EQ("780,75", env->last_mouse_location().ToString()); 376 EXPECT_EQ("780,75", env->last_mouse_location().ToString());
377 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); 377 EXPECT_EQ("400,0 400x300", GetViewport().ToString());
378 378
379 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 150)); 379 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 150));
380 EXPECT_EQ("799,75", env->last_mouse_location().ToString()); 380 EXPECT_EQ("799,75", env->last_mouse_location().ToString());
381 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); 381 EXPECT_EQ("400,0 400x300", GetViewport().ToString());
382 } 382 }
383 383
384 TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) { 384 TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) {
385 const aura::Env* env = aura::Env::GetInstance(); 385 aura::Env* env = aura::Env::GetInstance();
386 386
387 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); 387 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300));
388 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); 388 EXPECT_EQ(1.f, GetMagnificationController()->GetScale());
389 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); 389 EXPECT_EQ("0,0 800x600", GetViewport().ToString());
390 EXPECT_EQ("799,300", env->last_mouse_location().ToString()); 390 EXPECT_EQ("799,300", env->last_mouse_location().ToString());
391 391
392 // Enables magnifier and confirm the viewport is at center. 392 // Enables magnifier and confirm the viewport is at center.
393 GetMagnificationController()->SetEnabled(true); 393 GetMagnificationController()->SetEnabled(true);
394 394
395 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); 395 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); 427 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300));
428 EXPECT_EQ("50,300", env->last_mouse_location().ToString()); 428 EXPECT_EQ("50,300", env->last_mouse_location().ToString());
429 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); 429 EXPECT_EQ("0,150 400x300", GetViewport().ToString());
430 430
431 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); 431 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300));
432 EXPECT_EQ("0,300", env->last_mouse_location().ToString()); 432 EXPECT_EQ("0,300", env->last_mouse_location().ToString());
433 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); 433 EXPECT_EQ("0,150 400x300", GetViewport().ToString());
434 } 434 }
435 435
436 TEST_F(MagnificationControllerTest, PanWindowToRight) { 436 TEST_F(MagnificationControllerTest, PanWindowToRight) {
437 const aura::Env* env = aura::Env::GetInstance(); 437 aura::Env* env = aura::Env::GetInstance();
438 438
439 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); 439 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300));
440 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); 440 EXPECT_EQ(1.f, GetMagnificationController()->GetScale());
441 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); 441 EXPECT_EQ("0,0 800x600", GetViewport().ToString());
442 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); 442 EXPECT_EQ("400,300", env->last_mouse_location().ToString());
443 443
444 float scale = 2.f; 444 float scale = 2.f;
445 445
446 // Enables magnifier and confirm the viewport is at center. 446 // Enables magnifier and confirm the viewport is at center.
447 GetMagnificationController()->SetEnabled(true); 447 GetMagnificationController()->SetEnabled(true);
(...skipping 24 matching lines...) Expand all
472 472
473 scale *= kMagnificationScaleFactor; 473 scale *= kMagnificationScaleFactor;
474 GetMagnificationController()->SetScale(scale, false); 474 GetMagnificationController()->SetScale(scale, false);
475 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); 475 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale());
476 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); 476 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300));
477 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); 477 EXPECT_EQ("649,298", env->last_mouse_location().ToString());
478 EXPECT_EQ("704,300", GetHostMouseLocation()); 478 EXPECT_EQ("704,300", GetHostMouseLocation());
479 } 479 }
480 480
481 TEST_F(MagnificationControllerTest, PanWindowToLeft) { 481 TEST_F(MagnificationControllerTest, PanWindowToLeft) {
482 const aura::Env* env = aura::Env::GetInstance(); 482 aura::Env* env = aura::Env::GetInstance();
483 483
484 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); 484 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300));
485 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); 485 EXPECT_EQ(1.f, GetMagnificationController()->GetScale());
486 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); 486 EXPECT_EQ("0,0 800x600", GetViewport().ToString());
487 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); 487 EXPECT_EQ("400,300", env->last_mouse_location().ToString());
488 488
489 float scale = 2.f; 489 float scale = 2.f;
490 490
491 // Enables magnifier and confirm the viewport is at center. 491 // Enables magnifier and confirm the viewport is at center.
492 GetMagnificationController()->SetEnabled(true); 492 GetMagnificationController()->SetEnabled(true);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 UpdateDisplay("500x500"); 695 UpdateDisplay("500x500");
696 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); 696 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString());
697 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); 697 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale());
698 698
699 GetMagnificationController()->SetEnabled(false); 699 GetMagnificationController()->SetEnabled(false);
700 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); 700 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString());
701 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); 701 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale());
702 } 702 }
703 703
704 } // namespace ash 704 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/aura/BUILD.gn » ('j') | ui/aura/env.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698