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

Side by Side Diff: extensions/shell/browser/shell_screen_unittest.cc

Issue 2361283002: Add GetDisplayWithDisplayId to display::Screen. (Closed)
Patch Set: ref, test, etc 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 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 "extensions/shell/browser/shell_screen.h" 5 #include "extensions/shell/browser/shell_screen.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
11 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
12 #include "ui/aura/window_tree_host.h" 12 #include "ui/aura/window_tree_host.h"
13 #include "ui/display/display.h" 13 #include "ui/display/display.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 using ShellScreenTest = aura::test::AuraTestBase; 19 using ShellScreenTest = aura::test::AuraTestBase;
20 20
21 // Basic sanity tests for ShellScreen. 21 // Basic sanity tests for ShellScreen.
22 TEST_F(ShellScreenTest, ShellScreen) { 22 TEST_F(ShellScreenTest, ShellScreen) {
23 ShellScreen screen(gfx::Size(640, 480)); 23 ShellScreen screen(gfx::Size(640, 480));
24 24
25 // There is only one display. 25 // There is only one display.
26 EXPECT_EQ(1, screen.GetNumDisplays()); 26 EXPECT_EQ(1, screen.GetNumDisplays());
27 EXPECT_EQ(1u, screen.GetAllDisplays().size()); 27 EXPECT_EQ(1u, screen.GetAllDisplays().size());
28 EXPECT_EQ(0, screen.GetAllDisplays()[0].id()); 28 EXPECT_EQ(0, screen.GetAllDisplays()[0].id());
29 display::Display display;
30 bool has_display = screen.GetDisplayWithDisplayId(0, &display);
31 EXPECT_TRUE(has_display);
32 EXPECT_EQ(0, display.id());
29 EXPECT_EQ(0, screen.GetPrimaryDisplay().id()); 33 EXPECT_EQ(0, screen.GetPrimaryDisplay().id());
30 EXPECT_EQ("640x480", screen.GetPrimaryDisplay().size().ToString()); 34 EXPECT_EQ("640x480", display.size().ToString());
31 35
32 // Tests that reshaping the host window reshapes the display. 36 // Tests that reshaping the host window reshapes the display.
33 // NOTE: AuraTestBase already has its own WindowTreeHost. This is creating a 37 // NOTE: AuraTestBase already has its own WindowTreeHost. This is creating a
34 // second one. 38 // second one.
35 std::unique_ptr<aura::WindowTreeHost> host( 39 std::unique_ptr<aura::WindowTreeHost> host(
36 screen.CreateHostForPrimaryDisplay()); 40 screen.CreateHostForPrimaryDisplay());
37 EXPECT_TRUE(host->window()); 41 EXPECT_TRUE(host->window());
38 host->window()->SetBounds(gfx::Rect(0, 0, 800, 600)); 42 host->window()->SetBounds(gfx::Rect(0, 0, 800, 600));
39 EXPECT_EQ("800x600", screen.GetPrimaryDisplay().size().ToString()); 43 EXPECT_EQ("800x600", screen.GetPrimaryDisplay().size().ToString());
40 } 44 }
41 45
42 } // namespace extensions 46 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698