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

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

Issue 615133002: Add support for a virtual display on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix remaining comment periods (thanks achuithb@) Created 5 years, 10 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 "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/display/chromeos/test/action_logger_util.h" 10 #include "ui/display/chromeos/test/action_logger_util.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_EQ(modes[15], 297 EXPECT_EQ(modes[15],
298 DisplayConfigurator::FindDisplayModeMatchingSize( 298 DisplayConfigurator::FindDisplayModeMatchingSize(
299 output, gfx::Size(320, 200))); 299 output, gfx::Size(320, 200)));
300 300
301 // No mode found. 301 // No mode found.
302 EXPECT_EQ(NULL, 302 EXPECT_EQ(NULL,
303 DisplayConfigurator::FindDisplayModeMatchingSize( 303 DisplayConfigurator::FindDisplayModeMatchingSize(
304 output, gfx::Size(1440, 900))); 304 output, gfx::Size(1440, 900)));
305 } 305 }
306 306
307 TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) {
308 InitWithSingleOutput();
309
310 observer_.Reset();
311 const DisplayConfigurator::DisplayStateList* cached =
312 &configurator_.cached_displays();
313 ASSERT_EQ(static_cast<size_t>(1), cached->size());
314 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
315
316 // Add virtual display.
317 configurator_.EnableVirtualDisplay(make_scoped_ptr(new ui::DisplayMode(
318 big_mode_.size(), big_mode_.is_interlaced(), big_mode_.refresh_rate())));
319 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
320 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
321 configurator_.display_state());
322
323 // Virtual should not trigger addition of added crtc but does change FB
324 // height.
325 const int kDualHeight = small_mode_.size().height() +
326 DisplayConfigurator::kVerticalGap +
327 big_mode_.size().height();
328 EXPECT_EQ(
329 JoinActions(
330 kGrab,
331 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
332 &outputs_[0], NULL).c_str(),
333 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
334 kUngrab, NULL),
335 log_->GetActionsAndClear());
336 EXPECT_EQ(1, observer_.num_changes());
337 cached = &configurator_.cached_displays();
338 ASSERT_EQ(static_cast<size_t>(2), cached->size());
339 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
340 EXPECT_EQ(big_mode_.size(), (*cached)[1].display->current_mode()->size());
341
342 // Remove virtual display.
343 observer_.Reset();
344 configurator_.DisableVirtualDisplay();
345 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(),
346 &outputs_[0], NULL).c_str(),
347 GetCrtcAction(outputs_[0], &small_mode_,
348 gfx::Point(0, 0)).c_str(),
349 kUngrab, NULL),
350 log_->GetActionsAndClear());
351 EXPECT_EQ(1, observer_.num_changes());
352 cached = &configurator_.cached_displays();
353 ASSERT_EQ(static_cast<size_t>(1), cached->size());
354 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
355 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
356 }
357
307 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { 358 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
308 InitWithSingleOutput(); 359 InitWithSingleOutput();
309 360
310 // Connect a second output and check that the configurator enters 361 // Connect a second output and check that the configurator enters
311 // extended mode. 362 // extended mode.
312 observer_.Reset(); 363 observer_.Reset();
313 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 364 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
314 UpdateOutputs(2, true); 365 UpdateOutputs(2, true);
315 const int kDualHeight = small_mode_.size().height() + 366 const int kDualHeight = small_mode_.size().height() +
316 DisplayConfigurator::kVerticalGap + 367 DisplayConfigurator::kVerticalGap +
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 GetFramebufferAction(small_mode_.size(), &outputs_[0], 1349 GetFramebufferAction(small_mode_.size(), &outputs_[0],
1299 nullptr).c_str(), 1350 nullptr).c_str(),
1300 GetCrtcAction(outputs_[0], &small_mode_, 1351 GetCrtcAction(outputs_[0], &small_mode_,
1301 gfx::Point(0, 0)).c_str(), 1352 gfx::Point(0, 0)).c_str(),
1302 kUngrab, NULL), 1353 kUngrab, NULL),
1303 log_->GetActionsAndClear()); 1354 log_->GetActionsAndClear());
1304 } 1355 }
1305 1356
1306 } // namespace test 1357 } // namespace test
1307 } // namespace ui 1358 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698