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

Side by Side Diff: ui/display/chromeos/display_configurator_unittest.cc

Issue 2152303002: Allow idle/suspend with 3+ monitors attached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-power-state
Patch Set: . Created 4 years, 5 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
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 modes.push_back(small_mode_.Clone()); 164 modes.push_back(small_mode_.Clone());
165 modes.push_back(big_mode_.Clone()); 165 modes.push_back(big_mode_.Clone());
166 o = &outputs_[1]; 166 o = &outputs_[1];
167 o->set_current_mode(modes.back().get()); 167 o->set_current_mode(modes.back().get());
168 o->set_native_mode(modes.back().get()); 168 o->set_native_mode(modes.back().get());
169 o->set_modes(std::move(modes)); 169 o->set_modes(std::move(modes));
170 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); 170 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI);
171 o->set_is_aspect_preserving_scaling(true); 171 o->set_is_aspect_preserving_scaling(true);
172 o->set_display_id(456); 172 o->set_display_id(456);
173 173
174 modes.clear();
175 modes.push_back(small_mode_.Clone());
176 o = &outputs_[2];
177 o->set_current_mode(modes.back().get());
178 o->set_native_mode(modes.back().get());
179 o->set_modes(std::move(modes));
180 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI);
181 o->set_is_aspect_preserving_scaling(true);
182 o->set_display_id(789);
183
174 UpdateOutputs(2, false); 184 UpdateOutputs(2, false);
175 } 185 }
176 186
177 void OnConfiguredCallback(bool status) { 187 void OnConfiguredCallback(bool status) {
178 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); 188 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE);
179 } 189 }
180 190
181 void OnDisplayControlUpdated(bool status) { 191 void OnDisplayControlUpdated(bool status) {
182 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); 192 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE);
183 } 193 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 std::unique_ptr<ActionLogger> log_; 268 std::unique_ptr<ActionLogger> log_;
259 TestNativeDisplayDelegate* native_display_delegate_; // not owned 269 TestNativeDisplayDelegate* native_display_delegate_; // not owned
260 DisplayConfigurator::TestApi test_api_; 270 DisplayConfigurator::TestApi test_api_;
261 271
262 bool enable_content_protection_status_; 272 bool enable_content_protection_status_;
263 int enable_content_protection_call_count_; 273 int enable_content_protection_call_count_;
264 DisplayConfigurator::QueryProtectionResponse 274 DisplayConfigurator::QueryProtectionResponse
265 query_content_protection_response_; 275 query_content_protection_response_;
266 int query_content_protection_call_count_; 276 int query_content_protection_call_count_;
267 277
268 TestDisplaySnapshot outputs_[2]; 278 TestDisplaySnapshot outputs_[3];
269 279
270 CallbackResult callback_result_; 280 CallbackResult callback_result_;
271 CallbackResult display_control_result_; 281 CallbackResult display_control_result_;
272 282
273 private: 283 private:
274 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); 284 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest);
275 }; 285 };
276 286
277 } // namespace 287 } // namespace
278 288
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 .c_str(), 1840 .c_str(),
1831 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1841 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1832 GetCrtcAction(outputs_[1], &big_mode_, 1842 GetCrtcAction(outputs_[1], &big_mode_,
1833 gfx::Point(0, small_mode_.size().height() + 1843 gfx::Point(0, small_mode_.size().height() +
1834 DisplayConfigurator::kVerticalGap)) 1844 DisplayConfigurator::kVerticalGap))
1835 .c_str(), 1845 .c_str(),
1836 kUngrab, NULL), 1846 kUngrab, NULL),
1837 log_->GetActionsAndClear()); 1847 log_->GetActionsAndClear());
1838 } 1848 }
1839 1849
1850 TEST_F(DisplayConfiguratorTest, TestWithThreeDisplays) {
1851 // Start out with two displays in extended mode.
1852 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
1853 Init(false);
1854 configurator_.ForceInitialConfigure(0);
1855 log_->GetActionsAndClear();
1856 observer_.Reset();
1857
1858 UpdateOutputs(3, true);
1859 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED);
1860
1861 const int kDualHeight = small_mode_.size().height() +
1862 DisplayConfigurator::kVerticalGap +
1863 big_mode_.size().height();
1864 const int kTripleHeight = 2 * small_mode_.size().height() +
1865 2 * DisplayConfigurator::kVerticalGap +
1866 big_mode_.size().height();
1867 EXPECT_EQ(
1868 JoinActions(
1869 kGrab, GetFramebufferAction(
1870 gfx::Size(big_mode_.size().width(), kTripleHeight),
1871 &outputs_[0], &outputs_[1])
1872 .c_str(),
1873 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1874 GetCrtcAction(outputs_[1], &big_mode_,
1875 gfx::Point(0, small_mode_.size().height() +
1876 DisplayConfigurator::kVerticalGap))
1877 .c_str(),
1878 GetCrtcAction(
1879 outputs_[2], &small_mode_,
1880 gfx::Point(0, small_mode_.size().height() +
1881 big_mode_.size().height() +
1882 2 * DisplayConfigurator::kVerticalGap))
1883 .c_str(),
1884 kUngrab, NULL),
1885 log_->GetActionsAndClear());
1886
1887 // Verify that turning the power off works.
1888 configurator_.SetDisplayPower(
1889 chromeos::DISPLAY_POWER_ALL_OFF,
1890 DisplayConfigurator::kSetDisplayPowerNoFlags,
1891 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
1892 base::Unretained(this)));
1893
1894 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
1895 EXPECT_EQ(
1896 JoinActions(
1897 kGrab, GetFramebufferAction(
1898 gfx::Size(big_mode_.size().width(), kTripleHeight),
1899 &outputs_[0], &outputs_[1])
1900 .c_str(),
1901 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1902 GetCrtcAction(outputs_[1], nullptr,
1903 gfx::Point(0, small_mode_.size().height() +
1904 DisplayConfigurator::kVerticalGap))
1905 .c_str(),
1906 GetCrtcAction(
1907 outputs_[2], nullptr,
1908 gfx::Point(0, small_mode_.size().height() +
1909 big_mode_.size().height() +
1910 2 * DisplayConfigurator::kVerticalGap))
1911 .c_str(),
1912 kUngrab, NULL),
1913 log_->GetActionsAndClear());
1914
1915 configurator_.SetDisplayPower(
1916 chromeos::DISPLAY_POWER_ALL_ON,
1917 DisplayConfigurator::kSetDisplayPowerNoFlags,
1918 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
1919 base::Unretained(this)));
1920
1921 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
1922 EXPECT_EQ(
1923 JoinActions(
1924 kGrab, GetFramebufferAction(
1925 gfx::Size(big_mode_.size().width(), kTripleHeight),
1926 &outputs_[0], &outputs_[1])
1927 .c_str(),
1928 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1929 GetCrtcAction(outputs_[1], &big_mode_,
1930 gfx::Point(0, small_mode_.size().height() +
1931 DisplayConfigurator::kVerticalGap))
1932 .c_str(),
1933 GetCrtcAction(
1934 outputs_[2], &small_mode_,
1935 gfx::Point(0, small_mode_.size().height() +
1936 big_mode_.size().height() +
1937 2 * DisplayConfigurator::kVerticalGap))
1938 .c_str(),
1939 kForceDPMS, kUngrab, NULL),
1940 log_->GetActionsAndClear());
1941
1942 // Disconnect the third output.
1943 observer_.Reset();
1944 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
1945 UpdateOutputs(2, true);
1946 EXPECT_EQ(
1947 JoinActions(
1948 kGrab,
1949 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
1950 &outputs_[0], &outputs_[1])
1951 .c_str(),
1952 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1953 GetCrtcAction(outputs_[1], &big_mode_,
1954 gfx::Point(0, small_mode_.size().height() +
1955 DisplayConfigurator::kVerticalGap))
1956 .c_str(),
1957 kUngrab, NULL),
1958 log_->GetActionsAndClear());
1959 }
1960
1840 } // namespace test 1961 } // namespace test
1841 } // namespace ui 1962 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698