| Index: ui/display/chromeos/configure_displays_task_unittest.cc
|
| diff --git a/ui/display/chromeos/configure_displays_task_unittest.cc b/ui/display/chromeos/configure_displays_task_unittest.cc
|
| index 064cb7428d4ac902bc33d971999594dc518c87bf..347d8a28c84960cc84ce7c3a197dabf6dc30f8a7 100644
|
| --- a/ui/display/chromeos/configure_displays_task_unittest.cc
|
| +++ b/ui/display/chromeos/configure_displays_task_unittest.cc
|
| @@ -11,8 +11,8 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/display/chromeos/configure_displays_task.h"
|
| #include "ui/display/chromeos/test/action_logger_util.h"
|
| -#include "ui/display/chromeos/test/test_display_snapshot.h"
|
| #include "ui/display/chromeos/test/test_native_display_delegate.h"
|
| +#include "ui/display/fake_display_snapshot.h"
|
|
|
| namespace ui {
|
| namespace test {
|
| @@ -27,20 +27,18 @@ class ConfigureDisplaysTaskTest : public testing::Test {
|
| status_(ConfigureDisplaysTask::ERROR),
|
| small_mode_(gfx::Size(1366, 768), false, 60.0f),
|
| big_mode_(gfx::Size(2560, 1600), false, 60.0f) {
|
| - std::vector<std::unique_ptr<const DisplayMode>> modes;
|
| - modes.push_back(small_mode_.Clone());
|
| - displays_[0].set_current_mode(modes.front().get());
|
| - displays_[0].set_native_mode(modes.front().get());
|
| - displays_[0].set_modes(std::move(modes));
|
| - displays_[0].set_display_id(123);
|
| -
|
| - modes.clear();
|
| - modes.push_back(small_mode_.Clone());
|
| - modes.push_back(big_mode_.Clone());
|
| - displays_[1].set_current_mode(modes.back().get());
|
| - displays_[1].set_native_mode(modes.back().get());
|
| - displays_[1].set_modes(std::move(modes));
|
| - displays_[1].set_display_id(456);
|
| + displays_[0] = display::FakeDisplaySnapshot::Builder()
|
| + .SetId(123)
|
| + .SetNativeMode(small_mode_.Clone())
|
| + .SetCurrentMode(small_mode_.Clone())
|
| + .Build();
|
| +
|
| + displays_[1] = display::FakeDisplaySnapshot::Builder()
|
| + .SetId(456)
|
| + .SetNativeMode(big_mode_.Clone())
|
| + .SetCurrentMode(big_mode_.Clone())
|
| + .AddMode(small_mode_.Clone())
|
| + .Build();
|
| }
|
| ~ConfigureDisplaysTaskTest() override {}
|
|
|
| @@ -60,7 +58,7 @@ class ConfigureDisplaysTaskTest : public testing::Test {
|
| const DisplayMode small_mode_;
|
| const DisplayMode big_mode_;
|
|
|
| - TestDisplaySnapshot displays_[2];
|
| + std::unique_ptr<DisplaySnapshot> displays_[2];
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ConfigureDisplaysTaskTest);
|
| @@ -87,13 +85,14 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithOneDisplay) {
|
| &ConfigureDisplaysTaskTest::ConfigureCallback, base::Unretained(this));
|
|
|
| std::vector<DisplayConfigureRequest> requests(
|
| - 1, DisplayConfigureRequest(&displays_[0], &small_mode_, gfx::Point()));
|
| + 1,
|
| + DisplayConfigureRequest(displays_[0].get(), &small_mode_, gfx::Point()));
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| task.Run();
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::SUCCESS, status_);
|
| - EXPECT_EQ(GetCrtcAction(displays_[0], &small_mode_, gfx::Point()),
|
| + EXPECT_EQ(GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()),
|
| log_.GetActionsAndClear());
|
| }
|
|
|
| @@ -104,7 +103,7 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplay) {
|
| std::vector<DisplayConfigureRequest> requests;
|
| for (size_t i = 0; i < arraysize(displays_); ++i) {
|
| requests.push_back(DisplayConfigureRequest(
|
| - &displays_[i], displays_[i].native_mode(), gfx::Point()));
|
| + displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
|
| }
|
|
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| @@ -114,8 +113,9 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplay) {
|
| EXPECT_EQ(ConfigureDisplaysTask::SUCCESS, status_);
|
| EXPECT_EQ(
|
| JoinActions(
|
| - GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &big_mode_, gfx::Point()).c_str(), NULL),
|
| + GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| + nullptr),
|
| log_.GetActionsAndClear());
|
| }
|
|
|
| @@ -126,16 +126,16 @@ TEST_F(ConfigureDisplaysTaskTest, DisableDisplayFails) {
|
| delegate_.set_max_configurable_pixels(1);
|
|
|
| std::vector<DisplayConfigureRequest> requests(
|
| - 1, DisplayConfigureRequest(&displays_[0], nullptr, gfx::Point()));
|
| + 1, DisplayConfigureRequest(displays_[0].get(), nullptr, gfx::Point()));
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| task.Run();
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::ERROR, status_);
|
| - EXPECT_EQ(JoinActions(
|
| - GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(),
|
| - NULL),
|
| - log_.GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(GetCrtcAction(*displays_[0], nullptr, gfx::Point()).c_str(),
|
| + nullptr),
|
| + log_.GetActionsAndClear());
|
| }
|
|
|
| TEST_F(ConfigureDisplaysTaskTest, ConfigureWithOneDisplayFails) {
|
| @@ -145,17 +145,18 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithOneDisplayFails) {
|
| delegate_.set_max_configurable_pixels(1);
|
|
|
| std::vector<DisplayConfigureRequest> requests(
|
| - 1, DisplayConfigureRequest(&displays_[1], &big_mode_, gfx::Point()));
|
| + 1, DisplayConfigureRequest(displays_[1].get(), &big_mode_, gfx::Point()));
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| task.Run();
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::ERROR, status_);
|
| - EXPECT_EQ(JoinActions(
|
| - GetCrtcAction(displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| - NULL),
|
| - log_.GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + GetCrtcAction(*displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| + nullptr),
|
| + log_.GetActionsAndClear());
|
| }
|
|
|
| TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplayFails) {
|
| @@ -167,7 +168,7 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplayFails) {
|
| std::vector<DisplayConfigureRequest> requests;
|
| for (size_t i = 0; i < arraysize(displays_); ++i) {
|
| requests.push_back(DisplayConfigureRequest(
|
| - &displays_[i], displays_[i].native_mode(), gfx::Point()));
|
| + displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
|
| }
|
|
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| @@ -175,12 +176,13 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplayFails) {
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::ERROR, status_);
|
| - EXPECT_EQ(JoinActions(
|
| - GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| - NULL),
|
| - log_.GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| + nullptr),
|
| + log_.GetActionsAndClear());
|
| }
|
|
|
| TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplaysPartialSuccess) {
|
| @@ -192,7 +194,7 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplaysPartialSuccess) {
|
| std::vector<DisplayConfigureRequest> requests;
|
| for (size_t i = 0; i < arraysize(displays_); ++i) {
|
| requests.push_back(DisplayConfigureRequest(
|
| - &displays_[i], displays_[i].native_mode(), gfx::Point()));
|
| + displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
|
| }
|
|
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| @@ -200,12 +202,13 @@ TEST_F(ConfigureDisplaysTaskTest, ConfigureWithTwoDisplaysPartialSuccess) {
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::PARTIAL_SUCCESS, status_);
|
| - EXPECT_EQ(JoinActions(
|
| - GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| - NULL),
|
| - log_.GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| + nullptr),
|
| + log_.GetActionsAndClear());
|
| }
|
|
|
| TEST_F(ConfigureDisplaysTaskTest, AsyncConfigureWithTwoDisplaysPartialSuccess) {
|
| @@ -218,7 +221,7 @@ TEST_F(ConfigureDisplaysTaskTest, AsyncConfigureWithTwoDisplaysPartialSuccess) {
|
| std::vector<DisplayConfigureRequest> requests;
|
| for (size_t i = 0; i < arraysize(displays_); ++i) {
|
| requests.push_back(DisplayConfigureRequest(
|
| - &displays_[i], displays_[i].native_mode(), gfx::Point()));
|
| + displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
|
| }
|
|
|
| ConfigureDisplaysTask task(&delegate_, requests, callback);
|
| @@ -229,12 +232,13 @@ TEST_F(ConfigureDisplaysTaskTest, AsyncConfigureWithTwoDisplaysPartialSuccess) {
|
|
|
| EXPECT_TRUE(callback_called_);
|
| EXPECT_EQ(ConfigureDisplaysTask::PARTIAL_SUCCESS, status_);
|
| - EXPECT_EQ(JoinActions(
|
| - GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| - GetCrtcAction(displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| - NULL),
|
| - log_.GetActionsAndClear());
|
| + EXPECT_EQ(
|
| + JoinActions(
|
| + GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &big_mode_, gfx::Point()).c_str(),
|
| + GetCrtcAction(*displays_[1], &small_mode_, gfx::Point()).c_str(),
|
| + nullptr),
|
| + log_.GetActionsAndClear());
|
| }
|
|
|
| } // namespace test
|
|
|