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

Unified Diff: services/ui/display/platform_screen_ozone_unittests.cc

Issue 2340383002: Add FakeDisplaySnapshot builder and related changes. (Closed)
Patch Set: Fixes for comments. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/display/fake_display_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/display/platform_screen_ozone_unittests.cc
diff --git a/services/ui/display/platform_screen_ozone_unittests.cc b/services/ui/display/platform_screen_ozone_unittests.cc
index a931a7f4625fd4cde32b2c22ac16189c0cbf0e9e..824294ac280b935492e86300218a5b3a346d392f 100644
--- a/services/ui/display/platform_screen_ozone_unittests.cc
+++ b/services/ui/display/platform_screen_ozone_unittests.cc
@@ -5,6 +5,7 @@
#include <memory>
#include <vector>
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "services/ui/display/platform_screen.h"
@@ -12,7 +13,8 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/chromeos/display_configurator.h"
-#include "ui/display/chromeos/display_snapshot_virtual.h"
+#include "ui/display/display_switches.h"
+#include "ui/display/fake_display_snapshot.h"
#include "ui/display/types/display_constants.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
@@ -30,7 +32,7 @@ using testing::SizeIs;
namespace {
// The ID of default "display" that gets added when running off device.
-const int64_t kDefaultDisplayId = 36029742295586049;
+const int64_t kDefaultDisplayId = 1;
// Holds info about the display state we want to test.
struct DisplayState {
@@ -57,9 +59,11 @@ MATCHER_P(DisplayOrigin, origin_string, "") {
// Make a DisplaySnapshot with specified id and size.
std::unique_ptr<DisplaySnapshot> MakeSnapshot(int64_t id,
const gfx::Size& size) {
- auto snapshot = base::MakeUnique<DisplaySnapshotVirtual>(id, size);
- snapshot->set_current_mode(snapshot->modes()[0].get());
- return snapshot;
+ return FakeDisplaySnapshot::Builder()
+ .SetId(id)
+ .SetNativeMode(size)
+ .SetCurrentMode(size)
+ .Build();
}
// Test delegate to track what functions calls the delegate receives.
@@ -166,20 +170,24 @@ class PlatformScreenOzoneTest : public testing::Test {
// testing::Test:
void SetUp() override {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchNative(
+ switches::kScreenConfig, "none");
+
testing::Test::SetUp();
ui::OzonePlatform::InitializeForUI();
platform_screen_ = base::MakeUnique<PlatformScreenOzone>();
platform_screen_->Init(&delegate_);
+ // Have all tests start with a 1024x768 display by default.
+ AddDisplay(kDefaultDisplayId, gfx::Size(1024, 768));
+ TriggerOnDisplayModeChanged();
+
// Double check the expected display exists and clear counters.
ASSERT_THAT(delegate()->added(), SizeIs(1));
ASSERT_THAT(delegate_.added()[0], DisplayId(kDefaultDisplayId));
ASSERT_THAT(delegate_.added()[0], DisplayOrigin("0,0"));
ASSERT_THAT(delegate_.added()[0], DisplaySize("1024x768"));
delegate_.Reset();
-
- // Make the initial list of snapshots match what exists.
- AddDisplay(kDefaultDisplayId);
}
void TearDown() override {
« no previous file with comments | « no previous file | ui/display/fake_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698