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

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: Remove ash/ dep from content Created 5 years, 9 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_EQ(modes[15], 298 EXPECT_EQ(modes[15],
299 DisplayConfigurator::FindDisplayModeMatchingSize( 299 DisplayConfigurator::FindDisplayModeMatchingSize(
300 output, gfx::Size(320, 200))); 300 output, gfx::Size(320, 200)));
301 301
302 // No mode found. 302 // No mode found.
303 EXPECT_EQ(NULL, 303 EXPECT_EQ(NULL,
304 DisplayConfigurator::FindDisplayModeMatchingSize( 304 DisplayConfigurator::FindDisplayModeMatchingSize(
305 output, gfx::Size(1440, 900))); 305 output, gfx::Size(1440, 900)));
306 } 306 }
307 307
308 TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) {
309 InitWithSingleOutput();
310
311 observer_.Reset();
312 const DisplayConfigurator::DisplayStateList* cached =
313 &configurator_.cached_displays();
314 ASSERT_EQ(static_cast<size_t>(1), cached->size());
315 EXPECT_EQ(small_mode_.size(), (*cached)[0].display->current_mode()->size());
316
317 // Add virtual display.
318 configurator_.EnableVirtualDisplay(big_mode_.size());
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
308 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { 358 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
309 InitWithSingleOutput(); 359 InitWithSingleOutput();
310 360
311 // Connect a second output and check that the configurator enters 361 // Connect a second output and check that the configurator enters
312 // extended mode. 362 // extended mode.
313 observer_.Reset(); 363 observer_.Reset();
314 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 364 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
315 UpdateOutputs(2, true); 365 UpdateOutputs(2, true);
316 const int kDualHeight = small_mode_.size().height() + 366 const int kDualHeight = small_mode_.size().height() +
317 DisplayConfigurator::kVerticalGap + 367 DisplayConfigurator::kVerticalGap +
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 GetFramebufferAction(small_mode_.size(), &outputs_[0], 1398 GetFramebufferAction(small_mode_.size(), &outputs_[0],
1349 nullptr).c_str(), 1399 nullptr).c_str(),
1350 GetCrtcAction(outputs_[0], &small_mode_, 1400 GetCrtcAction(outputs_[0], &small_mode_,
1351 gfx::Point(0, 0)).c_str(), 1401 gfx::Point(0, 0)).c_str(),
1352 kUngrab, NULL), 1402 kUngrab, NULL),
1353 log_->GetActionsAndClear()); 1403 log_->GetActionsAndClear());
1354 } 1404 }
1355 1405
1356 } // namespace test 1406 } // namespace test
1357 } // namespace ui 1407 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | ui/display/chromeos/display_snapshot_virtual.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698