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

Unified Diff: ash/display/resolution_notification_controller_unittest.cc

Issue 2355063002: Separate ash::test::DisplayManagerTestApi from ash (Closed)
Patch Set: review comment Created 4 years, 2 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 | « ash/display/mouse_cursor_event_filter_unittest.cc ('k') | ash/display/root_window_transformers_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/resolution_notification_controller_unittest.cc
diff --git a/ash/display/resolution_notification_controller_unittest.cc b/ash/display/resolution_notification_controller_unittest.cc
index b5e7ccfc516876f1b677a912a18b789ffab52898..9446e4b551b462650ea9719f6ae99210ea38e0d5 100644
--- a/ash/display/resolution_notification_controller_unittest.cc
+++ b/ash/display/resolution_notification_controller_unittest.cc
@@ -18,32 +18,6 @@
#include "ui/message_center/notification_list.h"
namespace ash {
-namespace {
-
-base::string16 ExpectedNotificationMessage(int64_t display_id,
- const gfx::Size& new_resolution) {
- return l10n_util::GetStringFUTF16(
- IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED,
- base::UTF8ToUTF16(
- Shell::GetInstance()->display_manager()->GetDisplayNameForId(
- display_id)),
- base::UTF8ToUTF16(new_resolution.ToString()));
-}
-
-base::string16 ExpectedFallbackNotificationMessage(
- int64_t display_id,
- const gfx::Size& specified_resolution,
- const gfx::Size& fallback_resolution) {
- return l10n_util::GetStringFUTF16(
- IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED_TO_UNSUPPORTED,
- base::UTF8ToUTF16(
- Shell::GetInstance()->display_manager()->GetDisplayNameForId(
- display_id)),
- base::UTF8ToUTF16(specified_resolution.ToString()),
- base::UTF8ToUTF16(fallback_resolution.ToString()));
-}
-
-} // namespace
class ResolutionNotificationControllerTest : public ash::test::AshTestBase {
public:
@@ -51,6 +25,25 @@ class ResolutionNotificationControllerTest : public ash::test::AshTestBase {
~ResolutionNotificationControllerTest() override {}
+ base::string16 ExpectedNotificationMessage(int64_t display_id,
+ const gfx::Size& new_resolution) {
+ return l10n_util::GetStringFUTF16(
+ IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED,
+ base::UTF8ToUTF16(display_manager()->GetDisplayNameForId(display_id)),
+ base::UTF8ToUTF16(new_resolution.ToString()));
+ }
+
+ base::string16 ExpectedFallbackNotificationMessage(
+ int64_t display_id,
+ const gfx::Size& specified_resolution,
+ const gfx::Size& fallback_resolution) {
+ return l10n_util::GetStringFUTF16(
+ IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED_TO_UNSUPPORTED,
+ base::UTF8ToUTF16(display_manager()->GetDisplayNameForId(display_id)),
+ base::UTF8ToUTF16(specified_resolution.ToString()),
+ base::UTF8ToUTF16(fallback_resolution.ToString()));
+ }
+
protected:
void SetUp() override {
ash::test::AshTestBase::SetUp();
@@ -163,21 +156,19 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
return;
UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
ASSERT_EQ(0, accept_count());
EXPECT_FALSE(IsNotificationVisible());
// Changes the resolution and apply the result.
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
EXPECT_EQ(ExpectedNotificationMessage(id2, gfx::Size(200, 200)),
GetNotificationMessage());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(60.0, mode->refresh_rate());
@@ -187,7 +178,7 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- mode = display_manager->GetSelectedModeForDisplayId(id2);
+ mode = display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("250x250", mode->size().ToString());
EXPECT_EQ(59.0, mode->refresh_rate());
@@ -198,19 +189,17 @@ TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) {
return;
UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
ASSERT_EQ(0, accept_count());
EXPECT_FALSE(IsNotificationVisible());
// Changes the resolution and apply the result.
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(60.0, mode->refresh_rate());
@@ -220,7 +209,7 @@ TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) {
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
- mode = display_manager->GetSelectedModeForDisplayId(id2);
+ mode = display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(60.0, mode->refresh_rate());
@@ -230,9 +219,6 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
if (!SupportsMultipleDisplays())
return;
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
-
UpdateDisplay("300x300#300x300%59|200x200%60");
const display::Display& display =
display::Screen::GetScreen()->GetPrimaryDisplay();
@@ -247,7 +233,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
EXPECT_EQ(1, accept_count());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(display.id());
+ display_manager()->GetSelectedModeForDisplayId(display.id());
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
@@ -262,7 +248,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
ClickOnNotificationButton(1);
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
- mode = display_manager->GetSelectedModeForDisplayId(display.id());
+ mode = display_manager()->GetSelectedModeForDisplayId(display.id());
EXPECT_TRUE(!!mode);
EXPECT_EQ("300x300", mode->size().ToString());
@@ -274,19 +260,17 @@ TEST_F(ResolutionNotificationControllerTest, Close) {
return;
UpdateDisplay("100x100,150x150#150x150%59|200x200%60");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
ASSERT_EQ(0, accept_count());
EXPECT_FALSE(IsNotificationVisible());
// Changes the resolution and apply the result.
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(60.0f, mode->refresh_rate());
@@ -332,10 +316,8 @@ TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) {
UpdateDisplay(
"300x300#300x300%56|200x200%57,"
"200x200#250x250%58|200x200%59|100x100%60");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(100, 100));
ASSERT_TRUE(IsNotificationVisible());
@@ -345,7 +327,7 @@ TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) {
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
gfx::Size resolution;
EXPECT_EQ("200x200", mode->size().ToString());
@@ -359,25 +341,23 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
UpdateDisplay(
"300x300#300x300%56|200x200%57,"
"250x250#250x250%58|200x200%59");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(59.0f, mode->refresh_rate());
// Invokes SetDisplayResolutionAndNotify during the previous notification is
// visible.
- SetDisplayResolutionAndNotify(ScreenUtil::GetSecondaryDisplay(),
+ SetDisplayResolutionAndNotify(display_manager()->GetSecondaryDisplay(),
gfx::Size(250, 250));
- mode = display_manager->GetSelectedModeForDisplayId(id2);
+ mode = display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("250x250", mode->size().ToString());
EXPECT_EQ(58.0f, mode->refresh_rate());
@@ -389,7 +369,7 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- mode = display_manager->GetSelectedModeForDisplayId(id2);
+ mode = display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("250x250", mode->size().ToString());
EXPECT_EQ(58.0f, mode->refresh_rate());
@@ -402,23 +382,21 @@ TEST_F(ResolutionNotificationControllerTest, Fallback) {
UpdateDisplay(
"300x300#300x300%56|200x200%57,"
"250x250#250x250%58|220x220%59|200x200%60");
- int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
- ash::DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
+ int64_t id2 = display_manager()->GetSecondaryDisplay().id();
ASSERT_EQ(0, accept_count());
EXPECT_FALSE(IsNotificationVisible());
// Changes the resolution and apply the result.
- SetDisplayResolutionAndNotifyWithResolution(ScreenUtil::GetSecondaryDisplay(),
- gfx::Size(220, 220),
- gfx::Size(200, 200));
+ SetDisplayResolutionAndNotifyWithResolution(
+ display_manager()->GetSecondaryDisplay(), gfx::Size(220, 220),
+ gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
EXPECT_EQ(ExpectedFallbackNotificationMessage(id2, gfx::Size(220, 220),
gfx::Size(200, 200)),
GetNotificationMessage());
scoped_refptr<display::ManagedDisplayMode> mode =
- display_manager->GetSelectedModeForDisplayId(id2);
+ display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("200x200", mode->size().ToString());
EXPECT_EQ(60.0f, mode->refresh_rate());
@@ -429,7 +407,7 @@ TEST_F(ResolutionNotificationControllerTest, Fallback) {
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- mode = display_manager->GetSelectedModeForDisplayId(id2);
+ mode = display_manager()->GetSelectedModeForDisplayId(id2);
EXPECT_TRUE(!!mode);
EXPECT_EQ("250x250", mode->size().ToString());
EXPECT_EQ(58.0f, mode->refresh_rate());
« no previous file with comments | « ash/display/mouse_cursor_event_filter_unittest.cc ('k') | ash/display/root_window_transformers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698