| OLD | NEW | 
 | (Empty) | 
|    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 |  | 
|    3 // found in the LICENSE file. |  | 
|    4  |  | 
|    5 #include "ui/display/chromeos/update_display_configuration_task.h" |  | 
|    6  |  | 
|    7 #include <stddef.h> |  | 
|    8  |  | 
|    9 #include <utility> |  | 
|   10  |  | 
|   11 #include "base/bind.h" |  | 
|   12 #include "base/macros.h" |  | 
|   13 #include "base/memory/ptr_util.h" |  | 
|   14 #include "base/message_loop/message_loop.h" |  | 
|   15 #include "base/run_loop.h" |  | 
|   16 #include "testing/gtest/include/gtest/gtest.h" |  | 
|   17 #include "ui/display/chromeos/display_layout_manager.h" |  | 
|   18 #include "ui/display/chromeos/test/action_logger_util.h" |  | 
|   19 #include "ui/display/chromeos/test/test_native_display_delegate.h" |  | 
|   20 #include "ui/display/fake_display_snapshot.h" |  | 
|   21  |  | 
|   22 namespace ui { |  | 
|   23 namespace test { |  | 
|   24  |  | 
|   25 namespace { |  | 
|   26  |  | 
|   27 class TestSoftwareMirroringController |  | 
|   28     : public DisplayConfigurator::SoftwareMirroringController { |  | 
|   29  public: |  | 
|   30   TestSoftwareMirroringController() : is_enabled_(false) {} |  | 
|   31   ~TestSoftwareMirroringController() override {} |  | 
|   32  |  | 
|   33   // DisplayConfigurator::SoftwareMirroringController: |  | 
|   34   void SetSoftwareMirroring(bool enabled) override { is_enabled_ = enabled; } |  | 
|   35   bool SoftwareMirroringEnabled() const override { return is_enabled_; } |  | 
|   36  |  | 
|   37  private: |  | 
|   38   bool is_enabled_; |  | 
|   39  |  | 
|   40   DISALLOW_COPY_AND_ASSIGN(TestSoftwareMirroringController); |  | 
|   41 }; |  | 
|   42  |  | 
|   43 class TestDisplayLayoutManager : public DisplayLayoutManager { |  | 
|   44  public: |  | 
|   45   TestDisplayLayoutManager() |  | 
|   46       : should_mirror_(true), |  | 
|   47         display_state_(MULTIPLE_DISPLAY_STATE_INVALID), |  | 
|   48         power_state_(chromeos::DISPLAY_POWER_ALL_ON) {} |  | 
|   49   ~TestDisplayLayoutManager() override {} |  | 
|   50  |  | 
|   51   void set_should_mirror(bool should_mirror) { should_mirror_ = should_mirror; } |  | 
|   52  |  | 
|   53   void set_display_state(MultipleDisplayState state) { display_state_ = state; } |  | 
|   54  |  | 
|   55   void set_power_state(chromeos::DisplayPowerState state) { |  | 
|   56     power_state_ = state; |  | 
|   57   } |  | 
|   58  |  | 
|   59   void set_software_mirroring_controller( |  | 
|   60       std::unique_ptr<DisplayConfigurator::SoftwareMirroringController> |  | 
|   61           software_mirroring_controller) { |  | 
|   62     software_mirroring_controller_ = std::move(software_mirroring_controller); |  | 
|   63   } |  | 
|   64  |  | 
|   65   // DisplayConfigurator::DisplayLayoutManager: |  | 
|   66   DisplayConfigurator::SoftwareMirroringController* |  | 
|   67   GetSoftwareMirroringController() const override { |  | 
|   68     return software_mirroring_controller_.get(); |  | 
|   69   } |  | 
|   70  |  | 
|   71   DisplayConfigurator::StateController* GetStateController() const override { |  | 
|   72     return nullptr; |  | 
|   73   } |  | 
|   74  |  | 
|   75   MultipleDisplayState GetDisplayState() const override { |  | 
|   76     return display_state_; |  | 
|   77   } |  | 
|   78  |  | 
|   79   chromeos::DisplayPowerState GetPowerState() const override { |  | 
|   80     return power_state_; |  | 
|   81   } |  | 
|   82  |  | 
|   83   bool GetDisplayLayout(const std::vector<DisplaySnapshot*>& displays, |  | 
|   84                         MultipleDisplayState new_display_state, |  | 
|   85                         chromeos::DisplayPowerState new_power_state, |  | 
|   86                         std::vector<DisplayConfigureRequest>* requests, |  | 
|   87                         gfx::Size* framebuffer_size) const override { |  | 
|   88     gfx::Point origin; |  | 
|   89     for (DisplaySnapshot* display : displays) { |  | 
|   90       const DisplayMode* mode = display->native_mode(); |  | 
|   91       if (new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) |  | 
|   92         mode = should_mirror_ ? FindMirrorMode(displays) : nullptr; |  | 
|   93  |  | 
|   94       if (!mode) |  | 
|   95         return false; |  | 
|   96  |  | 
|   97       if (new_power_state == chromeos::DISPLAY_POWER_ALL_ON) { |  | 
|   98         requests->push_back(DisplayConfigureRequest(display, mode, origin)); |  | 
|   99       } else { |  | 
|  100         requests->push_back(DisplayConfigureRequest(display, nullptr, origin)); |  | 
|  101       } |  | 
|  102  |  | 
|  103       if (new_display_state != MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { |  | 
|  104         origin.Offset(0, mode->size().height()); |  | 
|  105         framebuffer_size->SetToMax(gfx::Size(mode->size().width(), origin.y())); |  | 
|  106       } else { |  | 
|  107         *framebuffer_size = mode->size(); |  | 
|  108       } |  | 
|  109     } |  | 
|  110  |  | 
|  111     return true; |  | 
|  112   } |  | 
|  113  |  | 
|  114   DisplayConfigurator::DisplayStateList GetDisplayStates() const override { |  | 
|  115     NOTREACHED(); |  | 
|  116     return DisplayConfigurator::DisplayStateList(); |  | 
|  117   } |  | 
|  118  |  | 
|  119   bool IsMirroring() const override { |  | 
|  120     return display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR; |  | 
|  121   } |  | 
|  122  |  | 
|  123  private: |  | 
|  124   const DisplayMode* FindMirrorMode( |  | 
|  125       const std::vector<DisplaySnapshot*>& displays) const { |  | 
|  126     const DisplayMode* mode = displays[0]->native_mode(); |  | 
|  127     for (DisplaySnapshot* display : displays) { |  | 
|  128       if (mode->size().GetArea() > display->native_mode()->size().GetArea()) |  | 
|  129         mode = display->native_mode(); |  | 
|  130     } |  | 
|  131  |  | 
|  132     return mode; |  | 
|  133   } |  | 
|  134  |  | 
|  135   bool should_mirror_; |  | 
|  136  |  | 
|  137   MultipleDisplayState display_state_; |  | 
|  138  |  | 
|  139   chromeos::DisplayPowerState power_state_; |  | 
|  140  |  | 
|  141   std::unique_ptr<DisplayConfigurator::SoftwareMirroringController> |  | 
|  142       software_mirroring_controller_; |  | 
|  143  |  | 
|  144   DISALLOW_COPY_AND_ASSIGN(TestDisplayLayoutManager); |  | 
|  145 }; |  | 
|  146  |  | 
|  147 class UpdateDisplayConfigurationTaskTest : public testing::Test { |  | 
|  148  public: |  | 
|  149   UpdateDisplayConfigurationTaskTest() |  | 
|  150       : delegate_(&log_), |  | 
|  151         small_mode_(gfx::Size(1366, 768), false, 60.0f), |  | 
|  152         big_mode_(gfx::Size(2560, 1600), false, 60.0f), |  | 
|  153         configured_(false), |  | 
|  154         configuration_status_(false), |  | 
|  155         display_state_(MULTIPLE_DISPLAY_STATE_INVALID), |  | 
|  156         power_state_(chromeos::DISPLAY_POWER_ALL_ON) { |  | 
|  157     displays_[0] = display::FakeDisplaySnapshot::Builder() |  | 
|  158                        .SetId(123) |  | 
|  159                        .SetNativeMode(small_mode_.Clone()) |  | 
|  160                        .SetCurrentMode(small_mode_.Clone()) |  | 
|  161                        .Build(); |  | 
|  162  |  | 
|  163     displays_[1] = display::FakeDisplaySnapshot::Builder() |  | 
|  164                        .SetId(456) |  | 
|  165                        .SetNativeMode(big_mode_.Clone()) |  | 
|  166                        .SetCurrentMode(big_mode_.Clone()) |  | 
|  167                        .AddMode(small_mode_.Clone()) |  | 
|  168                        .Build(); |  | 
|  169   } |  | 
|  170   ~UpdateDisplayConfigurationTaskTest() override {} |  | 
|  171  |  | 
|  172   void UpdateDisplays(size_t count) { |  | 
|  173     std::vector<DisplaySnapshot*> displays; |  | 
|  174     for (size_t i = 0; i < count; ++i) |  | 
|  175       displays.push_back(displays_[i].get()); |  | 
|  176  |  | 
|  177     delegate_.set_outputs(displays); |  | 
|  178   } |  | 
|  179  |  | 
|  180   void ResponseCallback(bool success, |  | 
|  181                         const std::vector<DisplaySnapshot*>& displays, |  | 
|  182                         const gfx::Size& framebuffer_size, |  | 
|  183                         MultipleDisplayState new_display_state, |  | 
|  184                         chromeos::DisplayPowerState new_power_state) { |  | 
|  185     configured_ = true; |  | 
|  186     configuration_status_ = success; |  | 
|  187     display_states_ = displays; |  | 
|  188     display_state_ = new_display_state; |  | 
|  189     power_state_ = new_power_state; |  | 
|  190  |  | 
|  191     if (success) { |  | 
|  192       layout_manager_.set_display_state(display_state_); |  | 
|  193       layout_manager_.set_power_state(power_state_); |  | 
|  194     } |  | 
|  195   } |  | 
|  196  |  | 
|  197  protected: |  | 
|  198   ActionLogger log_; |  | 
|  199   TestNativeDisplayDelegate delegate_; |  | 
|  200   TestDisplayLayoutManager layout_manager_; |  | 
|  201  |  | 
|  202   const DisplayMode small_mode_; |  | 
|  203   const DisplayMode big_mode_; |  | 
|  204  |  | 
|  205   std::unique_ptr<DisplaySnapshot> displays_[2]; |  | 
|  206  |  | 
|  207   bool configured_; |  | 
|  208   bool configuration_status_; |  | 
|  209   std::vector<DisplaySnapshot*> display_states_; |  | 
|  210   MultipleDisplayState display_state_; |  | 
|  211   chromeos::DisplayPowerState power_state_; |  | 
|  212  |  | 
|  213  private: |  | 
|  214   DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTaskTest); |  | 
|  215 }; |  | 
|  216  |  | 
|  217 }  // namespace |  | 
|  218  |  | 
|  219 TEST_F(UpdateDisplayConfigurationTaskTest, HeadlessConfiguration) { |  | 
|  220   { |  | 
|  221     UpdateDisplayConfigurationTask task( |  | 
|  222         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_HEADLESS, |  | 
|  223         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  224         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  225                    base::Unretained(this))); |  | 
|  226     task.Run(); |  | 
|  227   } |  | 
|  228  |  | 
|  229   EXPECT_TRUE(configured_); |  | 
|  230   EXPECT_TRUE(configuration_status_); |  | 
|  231   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_HEADLESS, display_state_); |  | 
|  232   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, power_state_); |  | 
|  233   EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_.GetActionsAndClear()); |  | 
|  234 } |  | 
|  235  |  | 
|  236 TEST_F(UpdateDisplayConfigurationTaskTest, SingleConfiguration) { |  | 
|  237   UpdateDisplays(1); |  | 
|  238  |  | 
|  239   { |  | 
|  240     UpdateDisplayConfigurationTask task( |  | 
|  241         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_SINGLE, |  | 
|  242         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  243         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  244                    base::Unretained(this))); |  | 
|  245     task.Run(); |  | 
|  246   } |  | 
|  247  |  | 
|  248   EXPECT_TRUE(configured_); |  | 
|  249   EXPECT_TRUE(configuration_status_); |  | 
|  250   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, display_state_); |  | 
|  251   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, power_state_); |  | 
|  252   EXPECT_EQ( |  | 
|  253       JoinActions( |  | 
|  254           kGrab, |  | 
|  255           GetFramebufferAction(small_mode_.size(), displays_[0].get(), nullptr) |  | 
|  256               .c_str(), |  | 
|  257           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  258           kUngrab, nullptr), |  | 
|  259       log_.GetActionsAndClear()); |  | 
|  260 } |  | 
|  261  |  | 
|  262 TEST_F(UpdateDisplayConfigurationTaskTest, ExtendedConfiguration) { |  | 
|  263   UpdateDisplays(2); |  | 
|  264  |  | 
|  265   { |  | 
|  266     UpdateDisplayConfigurationTask task( |  | 
|  267         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |  | 
|  268         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  269         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  270                    base::Unretained(this))); |  | 
|  271     task.Run(); |  | 
|  272   } |  | 
|  273  |  | 
|  274   EXPECT_TRUE(configured_); |  | 
|  275   EXPECT_TRUE(configuration_status_); |  | 
|  276   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, display_state_); |  | 
|  277   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, power_state_); |  | 
|  278   EXPECT_EQ( |  | 
|  279       JoinActions( |  | 
|  280           kGrab, GetFramebufferAction(gfx::Size(big_mode_.size().width(), |  | 
|  281                                                 small_mode_.size().height() + |  | 
|  282                                                     big_mode_.size().height()), |  | 
|  283                                       displays_[0].get(), displays_[1].get()) |  | 
|  284                      .c_str(), |  | 
|  285           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  286           GetCrtcAction(*displays_[1], &big_mode_, |  | 
|  287                         gfx::Point(0, small_mode_.size().height())) |  | 
|  288               .c_str(), |  | 
|  289           kUngrab, nullptr), |  | 
|  290       log_.GetActionsAndClear()); |  | 
|  291 } |  | 
|  292  |  | 
|  293 TEST_F(UpdateDisplayConfigurationTaskTest, MirrorConfiguration) { |  | 
|  294   UpdateDisplays(2); |  | 
|  295  |  | 
|  296   { |  | 
|  297     UpdateDisplayConfigurationTask task( |  | 
|  298         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, |  | 
|  299         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  300         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  301                    base::Unretained(this))); |  | 
|  302     task.Run(); |  | 
|  303   } |  | 
|  304  |  | 
|  305   EXPECT_TRUE(configured_); |  | 
|  306   EXPECT_TRUE(configuration_status_); |  | 
|  307   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, display_state_); |  | 
|  308   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, power_state_); |  | 
|  309   EXPECT_EQ( |  | 
|  310       JoinActions( |  | 
|  311           kGrab, GetFramebufferAction(small_mode_.size(), displays_[0].get(), |  | 
|  312                                       displays_[1].get()) |  | 
|  313                      .c_str(), |  | 
|  314           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  315           GetCrtcAction(*displays_[1], &small_mode_, gfx::Point()).c_str(), |  | 
|  316           kUngrab, nullptr), |  | 
|  317       log_.GetActionsAndClear()); |  | 
|  318 } |  | 
|  319  |  | 
|  320 TEST_F(UpdateDisplayConfigurationTaskTest, FailMirrorConfiguration) { |  | 
|  321   layout_manager_.set_should_mirror(false); |  | 
|  322   UpdateDisplays(2); |  | 
|  323  |  | 
|  324   { |  | 
|  325     UpdateDisplayConfigurationTask task( |  | 
|  326         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, |  | 
|  327         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  328         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  329                    base::Unretained(this))); |  | 
|  330     task.Run(); |  | 
|  331   } |  | 
|  332  |  | 
|  333   EXPECT_TRUE(configured_); |  | 
|  334   EXPECT_FALSE(configuration_status_); |  | 
|  335   EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_.GetActionsAndClear()); |  | 
|  336 } |  | 
|  337  |  | 
|  338 TEST_F(UpdateDisplayConfigurationTaskTest, FailExtendedConfiguration) { |  | 
|  339   delegate_.set_max_configurable_pixels(1); |  | 
|  340   UpdateDisplays(2); |  | 
|  341  |  | 
|  342   { |  | 
|  343     UpdateDisplayConfigurationTask task( |  | 
|  344         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |  | 
|  345         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  346         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  347                    base::Unretained(this))); |  | 
|  348     task.Run(); |  | 
|  349   } |  | 
|  350  |  | 
|  351   EXPECT_TRUE(configured_); |  | 
|  352   EXPECT_FALSE(configuration_status_); |  | 
|  353   EXPECT_EQ( |  | 
|  354       JoinActions( |  | 
|  355           kGrab, GetFramebufferAction(gfx::Size(big_mode_.size().width(), |  | 
|  356                                                 small_mode_.size().height() + |  | 
|  357                                                     big_mode_.size().height()), |  | 
|  358                                       displays_[0].get(), displays_[1].get()) |  | 
|  359                      .c_str(), |  | 
|  360           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  361           GetCrtcAction(*displays_[1], &big_mode_, |  | 
|  362                         gfx::Point(0, small_mode_.size().height())) |  | 
|  363               .c_str(), |  | 
|  364           GetCrtcAction(*displays_[1], &small_mode_, |  | 
|  365                         gfx::Point(0, small_mode_.size().height())) |  | 
|  366               .c_str(), |  | 
|  367           kUngrab, nullptr), |  | 
|  368       log_.GetActionsAndClear()); |  | 
|  369 } |  | 
|  370  |  | 
|  371 TEST_F(UpdateDisplayConfigurationTaskTest, SingleChangePowerConfiguration) { |  | 
|  372   UpdateDisplays(1); |  | 
|  373  |  | 
|  374   { |  | 
|  375     UpdateDisplayConfigurationTask task( |  | 
|  376         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_SINGLE, |  | 
|  377         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  378         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  379                    base::Unretained(this))); |  | 
|  380     task.Run(); |  | 
|  381   } |  | 
|  382  |  | 
|  383   EXPECT_TRUE(configured_); |  | 
|  384   EXPECT_TRUE(configuration_status_); |  | 
|  385   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, display_state_); |  | 
|  386   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, power_state_); |  | 
|  387   EXPECT_EQ( |  | 
|  388       JoinActions( |  | 
|  389           kGrab, |  | 
|  390           GetFramebufferAction(small_mode_.size(), displays_[0].get(), nullptr) |  | 
|  391               .c_str(), |  | 
|  392           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  393           kUngrab, nullptr), |  | 
|  394       log_.GetActionsAndClear()); |  | 
|  395  |  | 
|  396   // Turn power off |  | 
|  397   { |  | 
|  398     UpdateDisplayConfigurationTask task( |  | 
|  399         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_SINGLE, |  | 
|  400         chromeos::DISPLAY_POWER_ALL_OFF, 0, 0, false, |  | 
|  401         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  402                    base::Unretained(this))); |  | 
|  403     task.Run(); |  | 
|  404   } |  | 
|  405  |  | 
|  406   EXPECT_TRUE(configuration_status_); |  | 
|  407   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, display_state_); |  | 
|  408   EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, power_state_); |  | 
|  409   EXPECT_EQ( |  | 
|  410       JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), |  | 
|  411                                               displays_[0].get(), nullptr) |  | 
|  412                              .c_str(), |  | 
|  413                   GetCrtcAction(*displays_[0], nullptr, gfx::Point()).c_str(), |  | 
|  414                   kUngrab, nullptr), |  | 
|  415       log_.GetActionsAndClear()); |  | 
|  416 } |  | 
|  417  |  | 
|  418 TEST_F(UpdateDisplayConfigurationTaskTest, NoopSoftwareMirrorConfiguration) { |  | 
|  419   layout_manager_.set_should_mirror(false); |  | 
|  420   layout_manager_.set_software_mirroring_controller( |  | 
|  421       base::MakeUnique<TestSoftwareMirroringController>()); |  | 
|  422   UpdateDisplays(2); |  | 
|  423  |  | 
|  424   { |  | 
|  425     UpdateDisplayConfigurationTask task( |  | 
|  426         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |  | 
|  427         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  428         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  429                    base::Unretained(this))); |  | 
|  430     task.Run(); |  | 
|  431   } |  | 
|  432  |  | 
|  433   log_.GetActionsAndClear(); |  | 
|  434  |  | 
|  435   { |  | 
|  436     UpdateDisplayConfigurationTask task( |  | 
|  437         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, |  | 
|  438         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  439         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  440                    base::Unretained(this))); |  | 
|  441     task.Run(); |  | 
|  442   } |  | 
|  443  |  | 
|  444   EXPECT_TRUE(configuration_status_); |  | 
|  445   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, display_state_); |  | 
|  446   EXPECT_TRUE(layout_manager_.GetSoftwareMirroringController() |  | 
|  447               ->SoftwareMirroringEnabled()); |  | 
|  448   EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_.GetActionsAndClear()); |  | 
|  449 } |  | 
|  450  |  | 
|  451 TEST_F(UpdateDisplayConfigurationTaskTest, |  | 
|  452        ForceConfigurationWhileGoingToSoftwareMirror) { |  | 
|  453   layout_manager_.set_should_mirror(false); |  | 
|  454   layout_manager_.set_software_mirroring_controller( |  | 
|  455       base::MakeUnique<TestSoftwareMirroringController>()); |  | 
|  456   UpdateDisplays(2); |  | 
|  457  |  | 
|  458   { |  | 
|  459     UpdateDisplayConfigurationTask task( |  | 
|  460         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |  | 
|  461         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |  | 
|  462         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  463                    base::Unretained(this))); |  | 
|  464     task.Run(); |  | 
|  465   } |  | 
|  466  |  | 
|  467   log_.GetActionsAndClear(); |  | 
|  468  |  | 
|  469   { |  | 
|  470     UpdateDisplayConfigurationTask task( |  | 
|  471         &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, |  | 
|  472         chromeos::DISPLAY_POWER_ALL_ON, 0, 0, true /* force_configure */, |  | 
|  473         base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |  | 
|  474                    base::Unretained(this))); |  | 
|  475     task.Run(); |  | 
|  476   } |  | 
|  477  |  | 
|  478   EXPECT_TRUE(configuration_status_); |  | 
|  479   EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, display_state_); |  | 
|  480   EXPECT_TRUE(layout_manager_.GetSoftwareMirroringController() |  | 
|  481               ->SoftwareMirroringEnabled()); |  | 
|  482   EXPECT_EQ( |  | 
|  483       JoinActions( |  | 
|  484           kGrab, GetFramebufferAction(gfx::Size(big_mode_.size().width(), |  | 
|  485                                                 small_mode_.size().height() + |  | 
|  486                                                     big_mode_.size().height()), |  | 
|  487                                       displays_[0].get(), displays_[1].get()) |  | 
|  488                      .c_str(), |  | 
|  489           GetCrtcAction(*displays_[0], &small_mode_, gfx::Point()).c_str(), |  | 
|  490           GetCrtcAction(*displays_[1], &big_mode_, |  | 
|  491                         gfx::Point(0, small_mode_.size().height())) |  | 
|  492               .c_str(), |  | 
|  493           kUngrab, nullptr), |  | 
|  494       log_.GetActionsAndClear()); |  | 
|  495 } |  | 
|  496  |  | 
|  497 }  // namespace test |  | 
|  498 }  // namespace ui |  | 
| OLD | NEW |