Commit 9077672a authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

[chromecast] Fixes to CastScreen display override

  * Original CL was missing a single and critical line.
  * This CL also adds unit tests to verify.

Bug: internal b/138446155
Bug: internal b/141369532
Test: manual and unit test
Change-Id: I99707882c716fc371aa28aa29700f85eecb26638
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816534Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698568}
parent 025f7a53
......@@ -127,6 +127,7 @@ if (use_aura && !is_cast_audio_only) {
"accessibility/partial_magnification_controller_unittest.cc",
"cast_display_util_unittest.cc",
"cast_focus_client_aura_test.cc",
"cast_screen_unittest.cc",
"cast_touch_event_gate_test.cc",
"cast_views_test.cc",
"cast_window_manager_aura_test.cc",
......
......@@ -54,11 +54,14 @@ void CastScreen::OverridePrimaryDisplaySettings(
stashed_display_settings_ = primary_display;
LOG(INFO) << "Stashing primary display settings; device_scale_factor: "
LOG(INFO) << "Stashing primary display (" << primary_display.id()
<< ") settings; device_scale_factor: "
<< stashed_display_settings_->device_scale_factor()
<< " rotation: " << stashed_display_settings_->RotationAsDegree()
<< " size (pixels): "
<< stashed_display_settings_->GetSizeInPixel().ToString();
OnDisplayChanged(primary_display.id(), scale_factor, rotation, bounds);
}
bool CastScreen::RestorePrimaryDisplaySettings() {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/graphics/cast_screen.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/display/display_observer.h"
using testing::_;
using testing::AllOf;
using testing::Property;
namespace chromecast {
namespace test {
namespace {
constexpr int64_t kMockDisplayId = 0xcafebabe;
}
using CastScreenTest = aura::test::AuraTestBase;
class MockDisplayObserver : public display::DisplayObserver {
public:
MOCK_METHOD2(OnDisplayMetricsChanged,
void(const display::Display& display, uint32_t changed_metrics));
};
TEST_F(CastScreenTest, OverrideAndRestore) {
MockDisplayObserver mock_display_observer;
CastScreen screen;
// Set up initial screen.
screen.OnDisplayChanged(kMockDisplayId, 1.0,
display::Display::Rotation::ROTATE_0,
gfx::Rect(0, 0, 1920, 1080));
EXPECT_CALL(mock_display_observer,
OnDisplayMetricsChanged(
AllOf(Property(&display::Display::id, kMockDisplayId),
Property(&display::Display::device_scale_factor, 2.2),
Property(&display::Display::rotation,
display::Display::Rotation::ROTATE_270)),
_));
EXPECT_CALL(mock_display_observer,
OnDisplayMetricsChanged(
AllOf(Property(&display::Display::id, kMockDisplayId),
Property(&display::Display::device_scale_factor, 1.0),
Property(&display::Display::rotation,
display::Display::Rotation::ROTATE_0)),
_));
screen.AddObserver(&mock_display_observer);
screen.OverridePrimaryDisplaySettings(gfx::Rect(0, 0, 1000, 1000), 2.2,
display::Display::Rotation::ROTATE_270);
screen.RestorePrimaryDisplaySettings();
}
} // namespace test
} // namespace chromecast
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment