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

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: Rebase on ToT 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 height
324 const int kDualHeight = small_mode_.size().height() +
325 DisplayConfigurator::kVerticalGap +
326 big_mode_.size().height();
327 EXPECT_EQ(
328 JoinActions(
329 kGrab,
330 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
331 &outputs_[0], NULL).c_str(),
332 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
333 kUngrab, NULL),
334 log_->GetActionsAndClear());
335 EXPECT_EQ(1, observer_.num_changes());
336 cached = &configurator_.cached_displays();
337 ASSERT_EQ(static_cast<size_t>(2), cached->size());
338 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
339 EXPECT_EQ(big_mode_.size(), (*cached)[1].display->current_mode()->size());
340
341 // Remove virtual display
342 observer_.Reset();
343 configurator_.DisableVirtualDisplay();
344 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(),
345 &outputs_[0], NULL).c_str(),
346 GetCrtcAction(outputs_[0], &small_mode_,
347 gfx::Point(0, 0)).c_str(),
348 kUngrab, NULL),
349 log_->GetActionsAndClear());
350 EXPECT_EQ(1, observer_.num_changes());
351 cached = &configurator_.cached_displays();
352 ASSERT_EQ(static_cast<size_t>(1), cached->size());
353 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
354 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
355 }
356
307 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { 357 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
308 InitWithSingleOutput(); 358 InitWithSingleOutput();
309 359
310 // Connect a second output and check that the configurator enters 360 // Connect a second output and check that the configurator enters
311 // extended mode. 361 // extended mode.
312 observer_.Reset(); 362 observer_.Reset();
313 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 363 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
314 UpdateOutputs(2, true); 364 UpdateOutputs(2, true);
315 const int kDualHeight = small_mode_.size().height() + 365 const int kDualHeight = small_mode_.size().height() +
316 DisplayConfigurator::kVerticalGap + 366 DisplayConfigurator::kVerticalGap +
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 GetFramebufferAction(small_mode_.size(), &outputs_[0], 1348 GetFramebufferAction(small_mode_.size(), &outputs_[0],
1299 nullptr).c_str(), 1349 nullptr).c_str(),
1300 GetCrtcAction(outputs_[0], &small_mode_, 1350 GetCrtcAction(outputs_[0], &small_mode_,
1301 gfx::Point(0, 0)).c_str(), 1351 gfx::Point(0, 0)).c_str(),
1302 kUngrab, NULL), 1352 kUngrab, NULL),
1303 log_->GetActionsAndClear()); 1353 log_->GetActionsAndClear());
1304 } 1354 }
1305 1355
1306 } // namespace test 1356 } // namespace test
1307 } // namespace ui 1357 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698