| 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 "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <cstdarg> | 10 #include <cstdarg> |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 432 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 433 }; | 433 }; |
| 434 | 434 |
| 435 } // namespace | 435 } // namespace |
| 436 | 436 |
| 437 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { | 437 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| 438 ScopedVector<const DisplayMode> modes; | 438 ScopedVector<const DisplayMode> modes; |
| 439 | 439 |
| 440 // Fields are width, height, interlaced, refresh rate. | 440 // Fields are width, height, interlaced, refresh rate. |
| 441 modes.push_back(new DisplayMode(gfx::Size(1920, 1200), false, 60.0)); | 441 modes.push_back(new DisplayMode(gfx::Size(1920, 1200), false, 60.0)); |
| 442 DisplayMode* native_mode = |
| 443 new DisplayMode(gfx::Size(1920, 1200), false, 50.0); |
| 444 modes.push_back(native_mode); |
| 442 // Different rates. | 445 // Different rates. |
| 443 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 30.0)); | 446 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 30.0)); |
| 444 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 50.0)); | 447 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 50.0)); |
| 445 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); | 448 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); |
| 446 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 0.0)); | 449 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 0.0)); |
| 447 // Interlaced vs non-interlaced. | 450 // Interlaced vs non-interlaced. |
| 448 modes.push_back(new DisplayMode(gfx::Size(1280, 720), true, 60.0)); | 451 modes.push_back(new DisplayMode(gfx::Size(1280, 720), true, 60.0)); |
| 449 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 40.0)); | 452 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 40.0)); |
| 450 // Interlaced only. | 453 // Interlaced only. |
| 451 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 0.0)); | 454 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 0.0)); |
| 452 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 40.0)); | 455 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 40.0)); |
| 453 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 60.0)); | 456 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 60.0)); |
| 454 // Mixed. | 457 // Mixed. |
| 455 modes.push_back(new DisplayMode(gfx::Size(1024, 600), true, 60.0)); | 458 modes.push_back(new DisplayMode(gfx::Size(1024, 600), true, 60.0)); |
| 456 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 40.0)); | 459 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 40.0)); |
| 457 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 50.0)); | 460 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 50.0)); |
| 458 // Just one interlaced mode. | 461 // Just one interlaced mode. |
| 459 modes.push_back(new DisplayMode(gfx::Size(640, 480), true, 60.0)); | 462 modes.push_back(new DisplayMode(gfx::Size(640, 480), true, 60.0)); |
| 460 // Refresh rate not available. | 463 // Refresh rate not available. |
| 461 modes.push_back(new DisplayMode(gfx::Size(320, 200), false, 0.0)); | 464 modes.push_back(new DisplayMode(gfx::Size(320, 200), false, 0.0)); |
| 462 | 465 |
| 463 TestDisplaySnapshot output; | 466 TestDisplaySnapshot output; |
| 464 output.set_modes(modes.get()); | 467 output.set_modes(modes.get()); |
| 468 output.set_native_mode(native_mode); |
| 465 | 469 |
| 466 EXPECT_EQ(modes[0], | 470 // Should pick native over highest refresh rate. |
| 471 EXPECT_EQ(modes[1], |
| 467 DisplayConfigurator::FindDisplayModeMatchingSize( | 472 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 468 output, gfx::Size(1920, 1200))); | 473 output, gfx::Size(1920, 1200))); |
| 469 | 474 |
| 470 // Should pick highest refresh rate. | 475 // Should pick highest refresh rate. |
| 471 EXPECT_EQ(modes[2], | 476 EXPECT_EQ(modes[3], |
| 472 DisplayConfigurator::FindDisplayModeMatchingSize( | 477 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 473 output, gfx::Size(1920, 1080))); | 478 output, gfx::Size(1920, 1080))); |
| 474 | 479 |
| 475 // Should pick non-interlaced mode. | 480 // Should pick non-interlaced mode. |
| 476 EXPECT_EQ(modes[6], | 481 EXPECT_EQ(modes[7], |
| 477 DisplayConfigurator::FindDisplayModeMatchingSize( | 482 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 478 output, gfx::Size(1280, 720))); | 483 output, gfx::Size(1280, 720))); |
| 479 | 484 |
| 480 // Interlaced only. Should pick one with the highest refresh rate in | 485 // Interlaced only. Should pick one with the highest refresh rate in |
| 481 // interlaced mode. | 486 // interlaced mode. |
| 482 EXPECT_EQ(modes[9], | 487 EXPECT_EQ(modes[10], |
| 483 DisplayConfigurator::FindDisplayModeMatchingSize( | 488 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 484 output, gfx::Size(1024, 768))); | 489 output, gfx::Size(1024, 768))); |
| 485 | 490 |
| 486 // Mixed: Should pick one with the highest refresh rate in | 491 // Mixed: Should pick one with the highest refresh rate in |
| 487 // interlaced mode. | 492 // interlaced mode. |
| 488 EXPECT_EQ(modes[12], | 493 EXPECT_EQ(modes[13], |
| 489 DisplayConfigurator::FindDisplayModeMatchingSize( | 494 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 490 output, gfx::Size(1024, 600))); | 495 output, gfx::Size(1024, 600))); |
| 491 | 496 |
| 492 // Just one interlaced mode. | 497 // Just one interlaced mode. |
| 493 EXPECT_EQ(modes[13], | 498 EXPECT_EQ(modes[14], |
| 494 DisplayConfigurator::FindDisplayModeMatchingSize( | 499 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 495 output, gfx::Size(640, 480))); | 500 output, gfx::Size(640, 480))); |
| 496 | 501 |
| 497 // Refresh rate not available. | 502 // Refresh rate not available. |
| 498 EXPECT_EQ(modes[14], | 503 EXPECT_EQ(modes[15], |
| 499 DisplayConfigurator::FindDisplayModeMatchingSize( | 504 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 500 output, gfx::Size(320, 200))); | 505 output, gfx::Size(320, 200))); |
| 501 | 506 |
| 502 // No mode found. | 507 // No mode found. |
| 503 EXPECT_EQ(NULL, | 508 EXPECT_EQ(NULL, |
| 504 DisplayConfigurator::FindDisplayModeMatchingSize( | 509 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 505 output, gfx::Size(1440, 900))); | 510 output, gfx::Size(1440, 900))); |
| 506 } | 511 } |
| 507 | 512 |
| 508 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { | 513 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 .c_str(), | 1400 .c_str(), |
| 1396 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1401 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1397 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1402 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1398 kForceDPMS, | 1403 kForceDPMS, |
| 1399 kUngrab, | 1404 kUngrab, |
| 1400 NULL), | 1405 NULL), |
| 1401 log_->GetActionsAndClear()); | 1406 log_->GetActionsAndClear()); |
| 1402 } | 1407 } |
| 1403 | 1408 |
| 1404 } // namespace ui | 1409 } // namespace ui |
| OLD | NEW |