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

Side by Side Diff: ash/display/display_manager_unittest.cc

Issue 1608733002: Remove ui/gfx/screen_type_delegate.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-4
Patch Set: fixes Created 4 years, 11 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 (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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_layout_store.h" 10 #include "ash/display/display_layout_store.h"
(...skipping 12 matching lines...) Expand all
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/env.h" 25 #include "ui/aura/env.h"
26 #include "ui/aura/window_observer.h" 26 #include "ui/aura/window_observer.h"
27 #include "ui/aura/window_tree_host.h" 27 #include "ui/aura/window_tree_host.h"
28 #include "ui/events/test/event_generator.h" 28 #include "ui/events/test/event_generator.h"
29 #include "ui/gfx/display.h" 29 #include "ui/gfx/display.h"
30 #include "ui/gfx/display_observer.h" 30 #include "ui/gfx/display_observer.h"
31 #include "ui/gfx/font_render_params.h" 31 #include "ui/gfx/font_render_params.h"
32 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
33 #include "ui/gfx/screen_type_delegate.h"
34 33
35 namespace ash { 34 namespace ash {
36 35
37 using std::vector; 36 using std::vector;
38 using std::string; 37 using std::string;
39 38
40 using base::StringPrintf; 39 using base::StringPrintf;
41 40
42 namespace { 41 namespace {
43 42
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 1520
1522 // Don't check root window destruction in unified mode. 1521 // Don't check root window destruction in unified mode.
1523 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1522 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1524 1523
1525 UpdateDisplay("400x500,300x200"); 1524 UpdateDisplay("400x500,300x200");
1526 1525
1527 // Enable after extended mode. 1526 // Enable after extended mode.
1528 display_manager()->SetUnifiedDesktopEnabled(true); 1527 display_manager()->SetUnifiedDesktopEnabled(true);
1529 1528
1530 // Defaults to the unified desktop. 1529 // Defaults to the unified desktop.
1531 gfx::Screen* screen = 1530 gfx::Screen* screen = gfx::Screen::GetScreen();
1532 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1533 // The 2nd display is scaled so that it has the same height as 1st display. 1531 // The 2nd display is scaled so that it has the same height as 1st display.
1534 // 300 * 500 / 200 + 400 = 1150. 1532 // 300 * 500 / 200 + 400 = 1150.
1535 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1533 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1536 1534
1537 display_manager()->SetMirrorMode(true); 1535 display_manager()->SetMirrorMode(true);
1538 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 1536 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
1539 1537
1540 display_manager()->SetMirrorMode(false); 1538 display_manager()->SetMirrorMode(false);
1541 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1539 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1542 1540
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); 1622 EXPECT_FALSE(display_manager()->IsInUnifiedMode());
1625 } 1623 }
1626 1624
1627 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) { 1625 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
1628 if (!SupportsMultipleDisplays()) 1626 if (!SupportsMultipleDisplays())
1629 return; 1627 return;
1630 // Don't check root window destruction in unified mode. 1628 // Don't check root window destruction in unified mode.
1631 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1629 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1632 1630
1633 display_manager()->SetUnifiedDesktopEnabled(true); 1631 display_manager()->SetUnifiedDesktopEnabled(true);
1634 gfx::Screen* screen = 1632 gfx::Screen* screen = gfx::Screen::GetScreen();
1635 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1636 1633
1637 // 2nd display is 2x. 1634 // 2nd display is 2x.
1638 UpdateDisplay("400x500,1000x800*2"); 1635 UpdateDisplay("400x500,1000x800*2");
1639 DisplayInfo info = 1636 DisplayInfo info =
1640 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); 1637 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
1641 EXPECT_EQ(2u, info.display_modes().size()); 1638 EXPECT_EQ(2u, info.display_modes().size());
1642 EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString()); 1639 EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString());
1643 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor); 1640 EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
1644 EXPECT_EQ("1025x500", info.display_modes()[1].size.ToString()); 1641 EXPECT_EQ("1025x500", info.display_modes()[1].size.ToString());
1645 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor); 1642 EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) { 1743 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) {
1747 if (!SupportsMultipleDisplays()) 1744 if (!SupportsMultipleDisplays())
1748 return; 1745 return;
1749 display_manager()->SetUnifiedDesktopEnabled(true); 1746 display_manager()->SetUnifiedDesktopEnabled(true);
1750 1747
1751 // Don't check root window destruction in unified mode. 1748 // Don't check root window destruction in unified mode.
1752 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1749 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1753 1750
1754 UpdateDisplay("400x500,300x200"); 1751 UpdateDisplay("400x500,300x200");
1755 1752
1756 gfx::Screen* screen = 1753 gfx::Screen* screen = gfx::Screen::GetScreen();
1757 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1758 const gfx::Display& display = screen->GetPrimaryDisplay(); 1754 const gfx::Display& display = screen->GetPrimaryDisplay();
1759 EXPECT_EQ("1150x500", display.size().ToString()); 1755 EXPECT_EQ("1150x500", display.size().ToString());
1760 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_90, 1756 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_90,
1761 gfx::Display::ROTATION_SOURCE_ACTIVE); 1757 gfx::Display::ROTATION_SOURCE_ACTIVE);
1762 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1758 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1763 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_0, 1759 display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_0,
1764 gfx::Display::ROTATION_SOURCE_ACTIVE); 1760 gfx::Display::ROTATION_SOURCE_ACTIVE);
1765 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 1761 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
1766 1762
1767 UpdateDisplay("400x500"); 1763 UpdateDisplay("400x500");
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 EXPECT_FALSE(SetDisplayUIScale(gfx::Display::kInvalidDisplayID, 1.0f)); 1829 EXPECT_FALSE(SetDisplayUIScale(gfx::Display::kInvalidDisplayID, 1.0f));
1834 } 1830 }
1835 1831
1836 class ScreenShutdownTest : public test::AshTestBase { 1832 class ScreenShutdownTest : public test::AshTestBase {
1837 public: 1833 public:
1838 ScreenShutdownTest() { 1834 ScreenShutdownTest() {
1839 } 1835 }
1840 ~ScreenShutdownTest() override {} 1836 ~ScreenShutdownTest() override {}
1841 1837
1842 void TearDown() override { 1838 void TearDown() override {
1843 gfx::Screen* orig_screen = 1839 gfx::Screen* orig_screen = gfx::Screen::GetScreen();
1844 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1845 AshTestBase::TearDown(); 1840 AshTestBase::TearDown();
1846 if (!SupportsMultipleDisplays()) 1841 if (!SupportsMultipleDisplays())
1847 return; 1842 return;
1848 gfx::Screen* screen = 1843 gfx::Screen* screen = gfx::Screen::GetScreen();
1849 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
1850 EXPECT_NE(orig_screen, screen); 1844 EXPECT_NE(orig_screen, screen);
1851 EXPECT_EQ(2, screen->GetNumDisplays()); 1845 EXPECT_EQ(2, screen->GetNumDisplays());
1852 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); 1846 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString());
1853 std::vector<gfx::Display> all = screen->GetAllDisplays(); 1847 std::vector<gfx::Display> all = screen->GetAllDisplays();
1854 EXPECT_EQ("500x300", all[0].size().ToString()); 1848 EXPECT_EQ("500x300", all[0].size().ToString());
1855 EXPECT_EQ("800x400", all[1].size().ToString()); 1849 EXPECT_EQ("800x400", all[1].size().ToString());
1856 } 1850 }
1857 1851
1858 private: 1852 private:
1859 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); 1853 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 layout_store->RegisterLayoutForDisplayIdPair(id2, id1, bad); 2011 layout_store->RegisterLayoutForDisplayIdPair(id2, id1, bad);
2018 2012
2019 EXPECT_EQ(good.ToString(), layout_store->GetRegisteredDisplayLayout( 2013 EXPECT_EQ(good.ToString(), layout_store->GetRegisteredDisplayLayout(
2020 CreateDisplayIdPair(id1, id2)) 2014 CreateDisplayIdPair(id1, id2))
2021 .ToString()); 2015 .ToString());
2022 } 2016 }
2023 2017
2024 #endif // OS_CHROMEOS 2018 #endif // OS_CHROMEOS
2025 2019
2026 } // namespace ash 2020 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698