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

Side by Side Diff: ui/display/screen_unittest.cc

Issue 2361283002: Add GetDisplayWithDisplayId to display::Screen. (Closed)
Patch Set: move unittest Created 4 years 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
« no previous file with comments | « ui/display/screen.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/screen.h" 5 #include "ui/display/screen.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/display/display.h" 8 #include "ui/display/display.h"
9 #include "ui/display/test/test_screen.h"
9 10
10 namespace display { 11 namespace display {
11 12
12 TEST(ScreenTest, GetPrimaryDisplaySize) { 13 namespace {
13 // We aren't actually testing that it's correct, just that it's sane. 14
15 const int DEFAULT_DISPLAY_ID = 0x1337;
16 const int DEFAULT_DISPLAY_WIDTH = 2560;
17 const int DEFAULT_DISPLAY_HEIGHT = 1440;
18
19 } // namespace
20
21 class ScreenTest : public testing::Test {
22 protected:
23 ScreenTest() {
24 const display::Display test_display = test_screen_.GetPrimaryDisplay();
25 display::Display display(test_display);
26 display.set_id(DEFAULT_DISPLAY_ID);
27 display.set_bounds(
28 gfx::Rect(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT));
29 test_screen_.display_list().RemoveDisplay(test_display.id());
30 test_screen_.display_list().AddDisplay(display,
31 display::DisplayList::Type::PRIMARY);
32 Screen::SetScreenInstance(&test_screen_);
33 }
34
35 ~ScreenTest() override { Screen::SetScreenInstance(nullptr); }
36
37 private:
38 display::test::TestScreen test_screen_;
39
40 DISALLOW_COPY_AND_ASSIGN(ScreenTest);
41 };
42
43 TEST_F(ScreenTest, GetPrimaryDisplaySize) {
14 const gfx::Size size = Screen::GetScreen()->GetPrimaryDisplay().size(); 44 const gfx::Size size = Screen::GetScreen()->GetPrimaryDisplay().size();
15 EXPECT_GE(size.width(), 1); 45 EXPECT_EQ(DEFAULT_DISPLAY_WIDTH, size.width());
16 EXPECT_GE(size.height(), 1); 46 EXPECT_EQ(DEFAULT_DISPLAY_HEIGHT, size.height());
17 } 47 }
18 48
19 TEST(ScreenTest, GetNumDisplays) { 49 TEST_F(ScreenTest, GetNumDisplays) {
20 // We aren't actually testing that it's correct, just that it's sane. 50 EXPECT_EQ(Screen::GetScreen()->GetNumDisplays(), 1);
21 EXPECT_GE(Screen::GetScreen()->GetNumDisplays(), 1); 51 }
52
53 TEST_F(ScreenTest, GetDisplayWithDisplayId) {
54 Display display;
55 EXPECT_TRUE(Screen::GetScreen()->GetDisplayWithDisplayId(DEFAULT_DISPLAY_ID,
56 &display));
57 EXPECT_EQ(DEFAULT_DISPLAY_ID, display.id());
58 EXPECT_EQ(DEFAULT_DISPLAY_WIDTH, display.size().width());
59 EXPECT_EQ(DEFAULT_DISPLAY_HEIGHT, display.size().height());
22 } 60 }
23 61
24 } // namespace 62 } // namespace
OLDNEW
« no previous file with comments | « ui/display/screen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698