OLD | NEW |
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 "extensions/browser/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/content/display/screen_orientation_controller_chromeos.h" | 8 #include "ash/content/display/screen_orientation_controller_chromeos.h" |
9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 void SetUp() override { | 32 void SetUp() override { |
33 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 33 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
34 ash::switches::kAshUseFirstDisplayAsInternal); | 34 ash::switches::kAshUseFirstDisplayAsInternal); |
35 ash::test::AshTestBase::SetUp(); | 35 ash::test::AshTestBase::SetUp(); |
36 } | 36 } |
37 | 37 |
38 protected: | 38 protected: |
39 void CallSetDisplayUnitInfo( | 39 void CallSetDisplayUnitInfo( |
40 const std::string& display_id, | 40 const std::string& display_id, |
41 const core_api::system_display::DisplayProperties& info, | 41 const api::system_display::DisplayProperties& info, |
42 bool* success, | 42 bool* success, |
43 std::string* error) { | 43 std::string* error) { |
44 // Reset error messsage. | 44 // Reset error messsage. |
45 (*error).clear(); | 45 (*error).clear(); |
46 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); | 46 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); |
47 } | 47 } |
48 | 48 |
49 bool DisplayExists(int64 display_id) const { | 49 bool DisplayExists(int64 display_id) const { |
50 const gfx::Display& display = | 50 const gfx::Display& display = |
51 GetDisplayManager()->GetDisplayForId(display_id); | 51 GetDisplayManager()->GetDisplayForId(display_id); |
52 return display.id() != gfx::Display::kInvalidDisplayID; | 52 return display.id() != gfx::Display::kInvalidDisplayID; |
53 } | 53 } |
54 | 54 |
55 ash::DisplayManager* GetDisplayManager() const { | 55 ash::DisplayManager* GetDisplayManager() const { |
56 return ash::Shell::GetInstance()->display_manager(); | 56 return ash::Shell::GetInstance()->display_manager(); |
57 } | 57 } |
58 | 58 |
59 ash::DisplayController* GetDisplayController() const { | 59 ash::DisplayController* GetDisplayController() const { |
60 return ash::Shell::GetInstance()->display_controller(); | 60 return ash::Shell::GetInstance()->display_controller(); |
61 } | 61 } |
62 | 62 |
63 std::string SystemInfoDisplayInsetsToString( | 63 std::string SystemInfoDisplayInsetsToString( |
64 const core_api::system_display::Insets& insets) const { | 64 const api::system_display::Insets& insets) const { |
65 // Order to match gfx::Insets::ToString(). | 65 // Order to match gfx::Insets::ToString(). |
66 return base::StringPrintf( | 66 return base::StringPrintf( |
67 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); | 67 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); |
68 } | 68 } |
69 | 69 |
70 std::string SystemInfoDisplayBoundsToString( | 70 std::string SystemInfoDisplayBoundsToString( |
71 const core_api::system_display::Bounds& bounds) const { | 71 const api::system_display::Bounds& bounds) const { |
72 // Order to match gfx::Rect::ToString(). | 72 // Order to match gfx::Rect::ToString(). |
73 return base::StringPrintf( | 73 return base::StringPrintf( |
74 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); | 74 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); | 78 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); |
79 }; | 79 }; |
80 | 80 |
81 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { | 81 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 ASSERT_EQ(2u, result.size()); | 321 ASSERT_EQ(2u, result.size()); |
322 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 322 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
323 EXPECT_EQ("80,600 400x520", | 323 EXPECT_EQ("80,600 400x520", |
324 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 324 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
325 } | 325 } |
326 | 326 |
327 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { | 327 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { |
328 UpdateDisplay("1200x600,520x400"); | 328 UpdateDisplay("1200x600,520x400"); |
329 | 329 |
330 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 330 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
331 core_api::system_display::DisplayProperties info; | 331 api::system_display::DisplayProperties info; |
332 info.bounds_origin_x.reset(new int(-520)); | 332 info.bounds_origin_x.reset(new int(-520)); |
333 info.bounds_origin_y.reset(new int(50)); | 333 info.bounds_origin_y.reset(new int(50)); |
334 | 334 |
335 bool success = false; | 335 bool success = false; |
336 std::string error; | 336 std::string error; |
337 CallSetDisplayUnitInfo( | 337 CallSetDisplayUnitInfo( |
338 base::Int64ToString(secondary.id()), info, &success, &error); | 338 base::Int64ToString(secondary.id()), info, &success, &error); |
339 | 339 |
340 ASSERT_TRUE(success); | 340 ASSERT_TRUE(success); |
341 ASSERT_TRUE(error.empty()); | 341 ASSERT_TRUE(error.empty()); |
342 | 342 |
343 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); | 343 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); |
344 } | 344 } |
345 | 345 |
346 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { | 346 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { |
347 UpdateDisplay("1200x600,520x400"); | 347 UpdateDisplay("1200x600,520x400"); |
348 | 348 |
349 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 349 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
350 core_api::system_display::DisplayProperties info; | 350 api::system_display::DisplayProperties info; |
351 info.bounds_origin_x.reset(new int(1200)); | 351 info.bounds_origin_x.reset(new int(1200)); |
352 info.bounds_origin_y.reset(new int(100)); | 352 info.bounds_origin_y.reset(new int(100)); |
353 | 353 |
354 bool success = false; | 354 bool success = false; |
355 std::string error; | 355 std::string error; |
356 CallSetDisplayUnitInfo( | 356 CallSetDisplayUnitInfo( |
357 base::Int64ToString(secondary.id()), info, &success, &error); | 357 base::Int64ToString(secondary.id()), info, &success, &error); |
358 | 358 |
359 ASSERT_TRUE(success); | 359 ASSERT_TRUE(success); |
360 ASSERT_TRUE(error.empty()); | 360 ASSERT_TRUE(error.empty()); |
361 | 361 |
362 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 362 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
363 } | 363 } |
364 | 364 |
365 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { | 365 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { |
366 UpdateDisplay("1200x600,520x400"); | 366 UpdateDisplay("1200x600,520x400"); |
367 | 367 |
368 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 368 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
369 core_api::system_display::DisplayProperties info; | 369 api::system_display::DisplayProperties info; |
370 info.bounds_origin_x.reset(new int(1100)); | 370 info.bounds_origin_x.reset(new int(1100)); |
371 info.bounds_origin_y.reset(new int(-400)); | 371 info.bounds_origin_y.reset(new int(-400)); |
372 | 372 |
373 bool success = false; | 373 bool success = false; |
374 std::string error; | 374 std::string error; |
375 CallSetDisplayUnitInfo( | 375 CallSetDisplayUnitInfo( |
376 base::Int64ToString(secondary.id()), info, &success, &error); | 376 base::Int64ToString(secondary.id()), info, &success, &error); |
377 | 377 |
378 ASSERT_TRUE(success); | 378 ASSERT_TRUE(success); |
379 ASSERT_TRUE(error.empty()); | 379 ASSERT_TRUE(error.empty()); |
380 | 380 |
381 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); | 381 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); |
382 } | 382 } |
383 | 383 |
384 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { | 384 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { |
385 UpdateDisplay("1200x600,520x400"); | 385 UpdateDisplay("1200x600,520x400"); |
386 | 386 |
387 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 387 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
388 core_api::system_display::DisplayProperties info; | 388 api::system_display::DisplayProperties info; |
389 info.bounds_origin_x.reset(new int(-350)); | 389 info.bounds_origin_x.reset(new int(-350)); |
390 info.bounds_origin_y.reset(new int(600)); | 390 info.bounds_origin_y.reset(new int(600)); |
391 | 391 |
392 bool success = false; | 392 bool success = false; |
393 std::string error; | 393 std::string error; |
394 CallSetDisplayUnitInfo( | 394 CallSetDisplayUnitInfo( |
395 base::Int64ToString(secondary.id()), info, &success, &error); | 395 base::Int64ToString(secondary.id()), info, &success, &error); |
396 | 396 |
397 ASSERT_TRUE(success); | 397 ASSERT_TRUE(success); |
398 ASSERT_TRUE(error.empty()); | 398 ASSERT_TRUE(error.empty()); |
399 | 399 |
400 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); | 400 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); |
401 } | 401 } |
402 | 402 |
403 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { | 403 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { |
404 UpdateDisplay("1200x600,520x400"); | 404 UpdateDisplay("1200x600,520x400"); |
405 | 405 |
406 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 406 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
407 core_api::system_display::DisplayProperties info; | 407 api::system_display::DisplayProperties info; |
408 info.bounds_origin_x.reset(new int(340)); | 408 info.bounds_origin_x.reset(new int(340)); |
409 info.bounds_origin_y.reset(new int(100)); | 409 info.bounds_origin_y.reset(new int(100)); |
410 | 410 |
411 bool success = false; | 411 bool success = false; |
412 std::string error; | 412 std::string error; |
413 CallSetDisplayUnitInfo( | 413 CallSetDisplayUnitInfo( |
414 base::Int64ToString(secondary.id()), info, &success, &error); | 414 base::Int64ToString(secondary.id()), info, &success, &error); |
415 | 415 |
416 ASSERT_TRUE(success); | 416 ASSERT_TRUE(success); |
417 ASSERT_TRUE(error.empty()); | 417 ASSERT_TRUE(error.empty()); |
418 | 418 |
419 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 419 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
420 } | 420 } |
421 | 421 |
422 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { | 422 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { |
423 UpdateDisplay("1200x600,520x400"); | 423 UpdateDisplay("1200x600,520x400"); |
424 | 424 |
425 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 425 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
426 core_api::system_display::DisplayProperties info; | 426 api::system_display::DisplayProperties info; |
427 info.bounds_origin_x.reset(new int(-1040)); | 427 info.bounds_origin_x.reset(new int(-1040)); |
428 info.bounds_origin_y.reset(new int(100)); | 428 info.bounds_origin_y.reset(new int(100)); |
429 | 429 |
430 bool success = false; | 430 bool success = false; |
431 std::string error; | 431 std::string error; |
432 CallSetDisplayUnitInfo( | 432 CallSetDisplayUnitInfo( |
433 base::Int64ToString(secondary.id()), info, &success, &error); | 433 base::Int64ToString(secondary.id()), info, &success, &error); |
434 | 434 |
435 ASSERT_TRUE(success); | 435 ASSERT_TRUE(success); |
436 ASSERT_TRUE(error.empty()); | 436 ASSERT_TRUE(error.empty()); |
437 | 437 |
438 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); | 438 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); |
439 } | 439 } |
440 | 440 |
441 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { | 441 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { |
442 UpdateDisplay("1200x600,520x400"); | 442 UpdateDisplay("1200x600,520x400"); |
443 | 443 |
444 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 444 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
445 core_api::system_display::DisplayProperties info; | 445 api::system_display::DisplayProperties info; |
446 info.bounds_origin_x.reset(new int(-360)); | 446 info.bounds_origin_x.reset(new int(-360)); |
447 info.bounds_origin_y.reset(new int(-301)); | 447 info.bounds_origin_y.reset(new int(-301)); |
448 | 448 |
449 bool success = false; | 449 bool success = false; |
450 std::string error; | 450 std::string error; |
451 CallSetDisplayUnitInfo( | 451 CallSetDisplayUnitInfo( |
452 base::Int64ToString(secondary.id()), info, &success, &error); | 452 base::Int64ToString(secondary.id()), info, &success, &error); |
453 | 453 |
454 ASSERT_TRUE(success); | 454 ASSERT_TRUE(success); |
455 ASSERT_TRUE(error.empty()); | 455 ASSERT_TRUE(error.empty()); |
456 | 456 |
457 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); | 457 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); |
458 } | 458 } |
459 | 459 |
460 TEST_F(DisplayInfoProviderChromeosTest, | 460 TEST_F(DisplayInfoProviderChromeosTest, |
461 SetBoundsOriginLeftButSharesBottomSide) { | 461 SetBoundsOriginLeftButSharesBottomSide) { |
462 UpdateDisplay("1200x600,1000x100"); | 462 UpdateDisplay("1200x600,1000x100"); |
463 | 463 |
464 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 464 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
465 core_api::system_display::DisplayProperties info; | 465 api::system_display::DisplayProperties info; |
466 info.bounds_origin_x.reset(new int(-650)); | 466 info.bounds_origin_x.reset(new int(-650)); |
467 info.bounds_origin_y.reset(new int(700)); | 467 info.bounds_origin_y.reset(new int(700)); |
468 | 468 |
469 bool success = false; | 469 bool success = false; |
470 std::string error; | 470 std::string error; |
471 CallSetDisplayUnitInfo( | 471 CallSetDisplayUnitInfo( |
472 base::Int64ToString(secondary.id()), info, &success, &error); | 472 base::Int64ToString(secondary.id()), info, &success, &error); |
473 | 473 |
474 ASSERT_TRUE(success); | 474 ASSERT_TRUE(success); |
475 ASSERT_TRUE(error.empty()); | 475 ASSERT_TRUE(error.empty()); |
476 | 476 |
477 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); | 477 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); |
478 } | 478 } |
479 | 479 |
480 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { | 480 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { |
481 UpdateDisplay("1200x600,1000x100"); | 481 UpdateDisplay("1200x600,1000x100"); |
482 | 482 |
483 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 483 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
484 core_api::system_display::DisplayProperties info; | 484 api::system_display::DisplayProperties info; |
485 info.bounds_origin_x.reset(new int(850)); | 485 info.bounds_origin_x.reset(new int(850)); |
486 info.bounds_origin_y.reset(new int(-150)); | 486 info.bounds_origin_y.reset(new int(-150)); |
487 | 487 |
488 bool success = false; | 488 bool success = false; |
489 std::string error; | 489 std::string error; |
490 CallSetDisplayUnitInfo( | 490 CallSetDisplayUnitInfo( |
491 base::Int64ToString(secondary.id()), info, &success, &error); | 491 base::Int64ToString(secondary.id()), info, &success, &error); |
492 | 492 |
493 ASSERT_TRUE(success); | 493 ASSERT_TRUE(success); |
494 ASSERT_TRUE(error.empty()); | 494 ASSERT_TRUE(error.empty()); |
495 | 495 |
496 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); | 496 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); |
497 } | 497 } |
498 | 498 |
499 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { | 499 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { |
500 UpdateDisplay("1200x600,1000x100/l"); | 500 UpdateDisplay("1200x600,1000x100/l"); |
501 | 501 |
502 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 502 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
503 core_api::system_display::DisplayProperties info; | 503 api::system_display::DisplayProperties info; |
504 info.bounds_origin_x.reset(new int(-150)); | 504 info.bounds_origin_x.reset(new int(-150)); |
505 info.bounds_origin_y.reset(new int(-650)); | 505 info.bounds_origin_y.reset(new int(-650)); |
506 | 506 |
507 bool success = false; | 507 bool success = false; |
508 std::string error; | 508 std::string error; |
509 CallSetDisplayUnitInfo( | 509 CallSetDisplayUnitInfo( |
510 base::Int64ToString(secondary.id()), info, &success, &error); | 510 base::Int64ToString(secondary.id()), info, &success, &error); |
511 | 511 |
512 ASSERT_TRUE(success); | 512 ASSERT_TRUE(success); |
513 ASSERT_TRUE(error.empty()); | 513 ASSERT_TRUE(error.empty()); |
514 | 514 |
515 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); | 515 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); |
516 } | 516 } |
517 | 517 |
518 TEST_F(DisplayInfoProviderChromeosTest, | 518 TEST_F(DisplayInfoProviderChromeosTest, |
519 SetBoundsOriginBottomButSharesRightSide) { | 519 SetBoundsOriginBottomButSharesRightSide) { |
520 UpdateDisplay("1200x600,1000x100/l"); | 520 UpdateDisplay("1200x600,1000x100/l"); |
521 | 521 |
522 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 522 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
523 core_api::system_display::DisplayProperties info; | 523 api::system_display::DisplayProperties info; |
524 info.bounds_origin_x.reset(new int(1350)); | 524 info.bounds_origin_x.reset(new int(1350)); |
525 info.bounds_origin_y.reset(new int(450)); | 525 info.bounds_origin_y.reset(new int(450)); |
526 | 526 |
527 bool success = false; | 527 bool success = false; |
528 std::string error; | 528 std::string error; |
529 CallSetDisplayUnitInfo( | 529 CallSetDisplayUnitInfo( |
530 base::Int64ToString(secondary.id()), info, &success, &error); | 530 base::Int64ToString(secondary.id()), info, &success, &error); |
531 | 531 |
532 ASSERT_TRUE(success); | 532 ASSERT_TRUE(success); |
533 ASSERT_TRUE(error.empty()); | 533 ASSERT_TRUE(error.empty()); |
534 | 534 |
535 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); | 535 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); |
536 } | 536 } |
537 | 537 |
538 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { | 538 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { |
539 UpdateDisplay("1200x600*2,500x500"); | 539 UpdateDisplay("1200x600*2,500x500"); |
540 | 540 |
541 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 541 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
542 core_api::system_display::DisplayProperties info; | 542 api::system_display::DisplayProperties info; |
543 info.bounds_origin_x.reset(new int(250)); | 543 info.bounds_origin_x.reset(new int(250)); |
544 info.bounds_origin_y.reset(new int(-100)); | 544 info.bounds_origin_y.reset(new int(-100)); |
545 | 545 |
546 bool success = false; | 546 bool success = false; |
547 std::string error; | 547 std::string error; |
548 CallSetDisplayUnitInfo( | 548 CallSetDisplayUnitInfo( |
549 base::Int64ToString(secondary.id()), info, &success, &error); | 549 base::Int64ToString(secondary.id()), info, &success, &error); |
550 | 550 |
551 ASSERT_TRUE(success); | 551 ASSERT_TRUE(success); |
552 ASSERT_TRUE(error.empty()); | 552 ASSERT_TRUE(error.empty()); |
553 | 553 |
554 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); | 554 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); |
555 } | 555 } |
556 | 556 |
557 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { | 557 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { |
558 UpdateDisplay("1200x600,600x1000*2"); | 558 UpdateDisplay("1200x600,600x1000*2"); |
559 | 559 |
560 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 560 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
561 core_api::system_display::DisplayProperties info; | 561 api::system_display::DisplayProperties info; |
562 info.bounds_origin_x.reset(new int(450)); | 562 info.bounds_origin_x.reset(new int(450)); |
563 info.bounds_origin_y.reset(new int(-100)); | 563 info.bounds_origin_y.reset(new int(-100)); |
564 | 564 |
565 bool success = false; | 565 bool success = false; |
566 std::string error; | 566 std::string error; |
567 CallSetDisplayUnitInfo( | 567 CallSetDisplayUnitInfo( |
568 base::Int64ToString(secondary.id()), info, &success, &error); | 568 base::Int64ToString(secondary.id()), info, &success, &error); |
569 | 569 |
570 ASSERT_TRUE(success); | 570 ASSERT_TRUE(success); |
571 ASSERT_TRUE(error.empty()); | 571 ASSERT_TRUE(error.empty()); |
572 | 572 |
573 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); | 573 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); |
574 } | 574 } |
575 | 575 |
576 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { | 576 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { |
577 UpdateDisplay("1200x600,600x1000*2"); | 577 UpdateDisplay("1200x600,600x1000*2"); |
578 | 578 |
579 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 579 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
580 core_api::system_display::DisplayProperties info; | 580 api::system_display::DisplayProperties info; |
581 info.bounds_origin_x.reset(new int(0x200001)); | 581 info.bounds_origin_x.reset(new int(0x200001)); |
582 info.bounds_origin_y.reset(new int(-100)); | 582 info.bounds_origin_y.reset(new int(-100)); |
583 | 583 |
584 bool success = false; | 584 bool success = false; |
585 std::string error; | 585 std::string error; |
586 CallSetDisplayUnitInfo( | 586 CallSetDisplayUnitInfo( |
587 base::Int64ToString(secondary.id()), info, &success, &error); | 587 base::Int64ToString(secondary.id()), info, &success, &error); |
588 | 588 |
589 ASSERT_FALSE(success); | 589 ASSERT_FALSE(success); |
590 ASSERT_EQ("Bounds origin x out of bounds.", error); | 590 ASSERT_EQ("Bounds origin x out of bounds.", error); |
591 | 591 |
592 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 592 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
593 } | 593 } |
594 | 594 |
595 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { | 595 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { |
596 UpdateDisplay("1200x600,600x1000*2"); | 596 UpdateDisplay("1200x600,600x1000*2"); |
597 | 597 |
598 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 598 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
599 core_api::system_display::DisplayProperties info; | 599 api::system_display::DisplayProperties info; |
600 info.bounds_origin_x.reset(new int(300)); | 600 info.bounds_origin_x.reset(new int(300)); |
601 info.bounds_origin_y.reset(new int(-0x200001)); | 601 info.bounds_origin_y.reset(new int(-0x200001)); |
602 | 602 |
603 bool success = false; | 603 bool success = false; |
604 std::string error; | 604 std::string error; |
605 CallSetDisplayUnitInfo( | 605 CallSetDisplayUnitInfo( |
606 base::Int64ToString(secondary.id()), info, &success, &error); | 606 base::Int64ToString(secondary.id()), info, &success, &error); |
607 | 607 |
608 ASSERT_FALSE(success); | 608 ASSERT_FALSE(success); |
609 ASSERT_EQ("Bounds origin y out of bounds.", error); | 609 ASSERT_EQ("Bounds origin y out of bounds.", error); |
610 | 610 |
611 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 611 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
612 } | 612 } |
613 | 613 |
614 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { | 614 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { |
615 UpdateDisplay("1200x4600,600x1000*2"); | 615 UpdateDisplay("1200x4600,600x1000*2"); |
616 | 616 |
617 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 617 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
618 core_api::system_display::DisplayProperties info; | 618 api::system_display::DisplayProperties info; |
619 info.bounds_origin_x.reset(new int(200000)); | 619 info.bounds_origin_x.reset(new int(200000)); |
620 info.bounds_origin_y.reset(new int(10)); | 620 info.bounds_origin_y.reset(new int(10)); |
621 | 621 |
622 bool success = false; | 622 bool success = false; |
623 std::string error; | 623 std::string error; |
624 CallSetDisplayUnitInfo( | 624 CallSetDisplayUnitInfo( |
625 base::Int64ToString(secondary.id()), info, &success, &error); | 625 base::Int64ToString(secondary.id()), info, &success, &error); |
626 | 626 |
627 ASSERT_TRUE(success); | 627 ASSERT_TRUE(success); |
628 EXPECT_TRUE(error.empty()); | 628 EXPECT_TRUE(error.empty()); |
629 | 629 |
630 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); | 630 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); |
631 } | 631 } |
632 | 632 |
633 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { | 633 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { |
634 UpdateDisplay("1200x600,600x1000*2"); | 634 UpdateDisplay("1200x600,600x1000*2"); |
635 | 635 |
636 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 636 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
637 core_api::system_display::DisplayProperties info; | 637 api::system_display::DisplayProperties info; |
638 info.bounds_origin_x.reset(new int(300)); | 638 info.bounds_origin_x.reset(new int(300)); |
639 info.is_primary.reset(new bool(true)); | 639 info.is_primary.reset(new bool(true)); |
640 | 640 |
641 bool success = false; | 641 bool success = false; |
642 std::string error; | 642 std::string error; |
643 CallSetDisplayUnitInfo( | 643 CallSetDisplayUnitInfo( |
644 base::Int64ToString(secondary.id()), info, &success, &error); | 644 base::Int64ToString(secondary.id()), info, &success, &error); |
645 | 645 |
646 ASSERT_FALSE(success); | 646 ASSERT_FALSE(success); |
647 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); | 647 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); |
648 | 648 |
649 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 649 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
650 // The operation failed because the primary property would be set before | 650 // The operation failed because the primary property would be set before |
651 // setting bounds. The primary display shouldn't have been changed, though. | 651 // setting bounds. The primary display shouldn't have been changed, though. |
652 EXPECT_NE(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 652 EXPECT_NE(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); |
653 } | 653 } |
654 | 654 |
655 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { | 655 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { |
656 UpdateDisplay("1200x600,600x1000*2"); | 656 UpdateDisplay("1200x600,600x1000*2"); |
657 | 657 |
658 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 658 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
659 const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); | 659 const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); |
660 | 660 |
661 core_api::system_display::DisplayProperties info; | 661 api::system_display::DisplayProperties info; |
662 info.bounds_origin_x.reset(new int(300)); | 662 info.bounds_origin_x.reset(new int(300)); |
663 info.mirroring_source_id.reset( | 663 info.mirroring_source_id.reset( |
664 new std::string(base::Int64ToString(primary.id()))); | 664 new std::string(base::Int64ToString(primary.id()))); |
665 | 665 |
666 bool success = false; | 666 bool success = false; |
667 std::string error; | 667 std::string error; |
668 CallSetDisplayUnitInfo( | 668 CallSetDisplayUnitInfo( |
669 base::Int64ToString(secondary.id()), info, &success, &error); | 669 base::Int64ToString(secondary.id()), info, &success, &error); |
670 | 670 |
671 ASSERT_FALSE(success); | 671 ASSERT_FALSE(success); |
672 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", | 672 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", |
673 error); | 673 error); |
674 } | 674 } |
675 | 675 |
676 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { | 676 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { |
677 UpdateDisplay("1200x600,600x1000*2"); | 677 UpdateDisplay("1200x600,600x1000*2"); |
678 | 678 |
679 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 679 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
680 core_api::system_display::DisplayProperties info; | 680 api::system_display::DisplayProperties info; |
681 info.rotation.reset(new int(90)); | 681 info.rotation.reset(new int(90)); |
682 | 682 |
683 bool success = false; | 683 bool success = false; |
684 std::string error; | 684 std::string error; |
685 CallSetDisplayUnitInfo( | 685 CallSetDisplayUnitInfo( |
686 base::Int64ToString(secondary.id()), info, &success, &error); | 686 base::Int64ToString(secondary.id()), info, &success, &error); |
687 | 687 |
688 ASSERT_TRUE(success); | 688 ASSERT_TRUE(success); |
689 EXPECT_TRUE(error.empty()); | 689 EXPECT_TRUE(error.empty()); |
690 | 690 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 724 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
725 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); | 725 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); |
726 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 726 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); |
727 } | 727 } |
728 | 728 |
729 // Tests that rotation changes made before entering maximize mode are restored | 729 // Tests that rotation changes made before entering maximize mode are restored |
730 // upon exiting maximize mode, and that a rotation lock is not set. | 730 // upon exiting maximize mode, and that a rotation lock is not set. |
731 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeMaximizeMode) { | 731 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeMaximizeMode) { |
732 ash::ScreenOrientationController* screen_orientation_controller = | 732 ash::ScreenOrientationController* screen_orientation_controller = |
733 ash::Shell::GetInstance()->screen_orientation_controller(); | 733 ash::Shell::GetInstance()->screen_orientation_controller(); |
734 core_api::system_display::DisplayProperties info; | 734 api::system_display::DisplayProperties info; |
735 info.rotation.reset(new int(90)); | 735 info.rotation.reset(new int(90)); |
736 | 736 |
737 bool success = false; | 737 bool success = false; |
738 std::string error; | 738 std::string error; |
739 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), | 739 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), |
740 info, &success, &error); | 740 info, &success, &error); |
741 | 741 |
742 ASSERT_TRUE(success); | 742 ASSERT_TRUE(success); |
743 EXPECT_TRUE(error.empty()); | 743 EXPECT_TRUE(error.empty()); |
744 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 744 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
(...skipping 23 matching lines...) Expand all Loading... |
768 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | 768 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
769 // Entering maximize mode enables accelerometer screen rotations. | 769 // Entering maximize mode enables accelerometer screen rotations. |
770 ash::Shell::GetInstance() | 770 ash::Shell::GetInstance() |
771 ->maximize_mode_controller() | 771 ->maximize_mode_controller() |
772 ->EnableMaximizeModeWindowManager(true); | 772 ->EnableMaximizeModeWindowManager(true); |
773 | 773 |
774 ASSERT_FALSE(ash::Shell::GetInstance() | 774 ASSERT_FALSE(ash::Shell::GetInstance() |
775 ->screen_orientation_controller() | 775 ->screen_orientation_controller() |
776 ->rotation_locked()); | 776 ->rotation_locked()); |
777 | 777 |
778 core_api::system_display::DisplayProperties info; | 778 api::system_display::DisplayProperties info; |
779 info.rotation.reset(new int(90)); | 779 info.rotation.reset(new int(90)); |
780 | 780 |
781 bool success = false; | 781 bool success = false; |
782 std::string error; | 782 std::string error; |
783 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), | 783 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), |
784 info, &success, &error); | 784 info, &success, &error); |
785 | 785 |
786 ASSERT_TRUE(success); | 786 ASSERT_TRUE(success); |
787 EXPECT_TRUE(error.empty()); | 787 EXPECT_TRUE(error.empty()); |
788 EXPECT_TRUE(ash::Shell::GetInstance() | 788 EXPECT_TRUE(ash::Shell::GetInstance() |
789 ->screen_orientation_controller() | 789 ->screen_orientation_controller() |
790 ->rotation_locked()); | 790 ->rotation_locked()); |
791 } | 791 } |
792 | 792 |
793 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 793 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
794 UpdateDisplay("1200x600,600x1000*2"); | 794 UpdateDisplay("1200x600,600x1000*2"); |
795 | 795 |
796 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 796 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
797 core_api::system_display::DisplayProperties info; | 797 api::system_display::DisplayProperties info; |
798 info.rotation.reset(new int(91)); | 798 info.rotation.reset(new int(91)); |
799 | 799 |
800 bool success = false; | 800 bool success = false; |
801 std::string error; | 801 std::string error; |
802 CallSetDisplayUnitInfo( | 802 CallSetDisplayUnitInfo( |
803 base::Int64ToString(secondary.id()), info, &success, &error); | 803 base::Int64ToString(secondary.id()), info, &success, &error); |
804 | 804 |
805 ASSERT_FALSE(success); | 805 ASSERT_FALSE(success); |
806 EXPECT_EQ("Invalid rotation.", error); | 806 EXPECT_EQ("Invalid rotation.", error); |
807 } | 807 } |
808 | 808 |
809 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { | 809 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { |
810 UpdateDisplay("1200x600,600x1000*2"); | 810 UpdateDisplay("1200x600,600x1000*2"); |
811 | 811 |
812 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 812 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
813 core_api::system_display::DisplayProperties info; | 813 api::system_display::DisplayProperties info; |
814 info.overscan.reset(new core_api::system_display::Insets); | 814 info.overscan.reset(new api::system_display::Insets); |
815 info.overscan->left = -10; | 815 info.overscan->left = -10; |
816 | 816 |
817 bool success = false; | 817 bool success = false; |
818 std::string error; | 818 std::string error; |
819 CallSetDisplayUnitInfo( | 819 CallSetDisplayUnitInfo( |
820 base::Int64ToString(secondary.id()), info, &success, &error); | 820 base::Int64ToString(secondary.id()), info, &success, &error); |
821 | 821 |
822 ASSERT_FALSE(success); | 822 ASSERT_FALSE(success); |
823 EXPECT_EQ("Negative overscan not allowed.", error); | 823 EXPECT_EQ("Negative overscan not allowed.", error); |
824 | 824 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 ASSERT_TRUE(success); | 866 ASSERT_TRUE(success); |
867 EXPECT_TRUE(error.empty()); | 867 EXPECT_TRUE(error.empty()); |
868 | 868 |
869 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 869 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
870 } | 870 } |
871 | 871 |
872 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { | 872 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { |
873 UpdateDisplay("1200x600,600x1000*2"); | 873 UpdateDisplay("1200x600,600x1000*2"); |
874 | 874 |
875 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 875 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
876 core_api::system_display::DisplayProperties info; | 876 api::system_display::DisplayProperties info; |
877 info.overscan.reset(new core_api::system_display::Insets); | 877 info.overscan.reset(new api::system_display::Insets); |
878 // Horizontal overscan is 151, which would make the bounds width 149. | 878 // Horizontal overscan is 151, which would make the bounds width 149. |
879 info.overscan->left = 50; | 879 info.overscan->left = 50; |
880 info.overscan->top = 10; | 880 info.overscan->top = 10; |
881 info.overscan->right = 101; | 881 info.overscan->right = 101; |
882 info.overscan->bottom = 20; | 882 info.overscan->bottom = 20; |
883 | 883 |
884 bool success = false; | 884 bool success = false; |
885 std::string error; | 885 std::string error; |
886 CallSetDisplayUnitInfo( | 886 CallSetDisplayUnitInfo( |
887 base::Int64ToString(secondary.id()), info, &success, &error); | 887 base::Int64ToString(secondary.id()), info, &success, &error); |
888 | 888 |
889 ASSERT_FALSE(success); | 889 ASSERT_FALSE(success); |
890 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", | 890 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", |
891 error); | 891 error); |
892 } | 892 } |
893 | 893 |
894 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { | 894 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { |
895 UpdateDisplay("1200x600,600x1000"); | 895 UpdateDisplay("1200x600,600x1000"); |
896 | 896 |
897 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 897 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
898 core_api::system_display::DisplayProperties info; | 898 api::system_display::DisplayProperties info; |
899 info.overscan.reset(new core_api::system_display::Insets); | 899 info.overscan.reset(new api::system_display::Insets); |
900 // Vertical overscan is 501, which would make the bounds height 499. | 900 // Vertical overscan is 501, which would make the bounds height 499. |
901 info.overscan->left = 20; | 901 info.overscan->left = 20; |
902 info.overscan->top = 250; | 902 info.overscan->top = 250; |
903 info.overscan->right = 101; | 903 info.overscan->right = 101; |
904 info.overscan->bottom = 251; | 904 info.overscan->bottom = 251; |
905 | 905 |
906 bool success = false; | 906 bool success = false; |
907 std::string error; | 907 std::string error; |
908 CallSetDisplayUnitInfo( | 908 CallSetDisplayUnitInfo( |
909 base::Int64ToString(secondary.id()), info, &success, &error); | 909 base::Int64ToString(secondary.id()), info, &success, &error); |
910 | 910 |
911 ASSERT_FALSE(success); | 911 ASSERT_FALSE(success); |
912 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); | 912 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); |
913 } | 913 } |
914 | 914 |
915 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { | 915 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { |
916 UpdateDisplay("1200x600,600x1000*2"); | 916 UpdateDisplay("1200x600,600x1000*2"); |
917 | 917 |
918 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 918 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
919 core_api::system_display::DisplayProperties info; | 919 api::system_display::DisplayProperties info; |
920 info.overscan.reset(new core_api::system_display::Insets); | 920 info.overscan.reset(new api::system_display::Insets); |
921 info.overscan->left = 20; | 921 info.overscan->left = 20; |
922 info.overscan->top = 199; | 922 info.overscan->top = 199; |
923 info.overscan->right = 130; | 923 info.overscan->right = 130; |
924 info.overscan->bottom = 51; | 924 info.overscan->bottom = 51; |
925 | 925 |
926 bool success = false; | 926 bool success = false; |
927 std::string error; | 927 std::string error; |
928 CallSetDisplayUnitInfo( | 928 CallSetDisplayUnitInfo( |
929 base::Int64ToString(secondary.id()), info, &success, &error); | 929 base::Int64ToString(secondary.id()), info, &success, &error); |
930 | 930 |
931 ASSERT_TRUE(success); | 931 ASSERT_TRUE(success); |
932 EXPECT_TRUE(error.empty()); | 932 EXPECT_TRUE(error.empty()); |
933 | 933 |
934 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); | 934 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); |
935 const gfx::Insets overscan = | 935 const gfx::Insets overscan = |
936 GetDisplayManager()->GetOverscanInsets(secondary.id()); | 936 GetDisplayManager()->GetOverscanInsets(secondary.id()); |
937 | 937 |
938 EXPECT_EQ(20, overscan.left()); | 938 EXPECT_EQ(20, overscan.left()); |
939 EXPECT_EQ(199, overscan.top()); | 939 EXPECT_EQ(199, overscan.top()); |
940 EXPECT_EQ(130, overscan.right()); | 940 EXPECT_EQ(130, overscan.right()); |
941 EXPECT_EQ(51, overscan.bottom()); | 941 EXPECT_EQ(51, overscan.bottom()); |
942 } | 942 } |
943 | 943 |
944 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { | 944 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { |
945 UpdateDisplay("1200x600,600x1000*2"); | 945 UpdateDisplay("1200x600,600x1000*2"); |
946 const int64 internal_display_id = | 946 const int64 internal_display_id = |
947 ash::test::DisplayManagerTestApi(GetDisplayManager()) | 947 ash::test::DisplayManagerTestApi(GetDisplayManager()) |
948 .SetFirstDisplayAsInternalDisplay(); | 948 .SetFirstDisplayAsInternalDisplay(); |
949 | 949 |
950 core_api::system_display::DisplayProperties info; | 950 api::system_display::DisplayProperties info; |
951 info.overscan.reset(new core_api::system_display::Insets); | 951 info.overscan.reset(new api::system_display::Insets); |
952 // Vertical overscan is 501, which would make the bounds height 499. | 952 // Vertical overscan is 501, which would make the bounds height 499. |
953 info.overscan->left = 20; | 953 info.overscan->left = 20; |
954 info.overscan->top = 20; | 954 info.overscan->top = 20; |
955 info.overscan->right = 20; | 955 info.overscan->right = 20; |
956 info.overscan->bottom = 20; | 956 info.overscan->bottom = 20; |
957 | 957 |
958 bool success = false; | 958 bool success = false; |
959 std::string error; | 959 std::string error; |
960 CallSetDisplayUnitInfo( | 960 CallSetDisplayUnitInfo( |
961 base::Int64ToString(internal_display_id), info, &success, &error); | 961 base::Int64ToString(internal_display_id), info, &success, &error); |
962 | 962 |
963 ASSERT_FALSE(success); | 963 ASSERT_FALSE(success); |
964 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); | 964 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); |
965 } | 965 } |
966 | 966 |
967 } // namespace | 967 } // namespace |
968 } // namespace extensions | 968 } // namespace extensions |
OLD | NEW |