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

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

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: rebase 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 | « no previous file | ash/display/display_util.cc » ('j') | 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/manager/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/display/display_configuration_controller.h" 10 #include "ash/display/display_configuration_controller.h"
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 // Connect another display which will become primary. 863 // Connect another display which will become primary.
864 const display::ManagedDisplayInfo external_display_info = 864 const display::ManagedDisplayInfo external_display_info =
865 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 865 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
866 display_info_list.push_back(external_display_info); 866 display_info_list.push_back(external_display_info);
867 display_manager()->OnNativeDisplaysChanged(display_info_list); 867 display_manager()->OnNativeDisplaysChanged(display_info_list);
868 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 868 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
869 EXPECT_EQ("1,1 100x100", 869 EXPECT_EQ("1,1 100x100",
870 GetDisplayInfoForId(10).bounds_in_native().ToString()); 870 GetDisplayInfoForId(10).bounds_in_native().ToString());
871 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() 871 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()
872 ->GetHost() 872 ->GetHost()
873 ->GetBounds() 873 ->GetBoundsInPixels()
874 .size() 874 .size()
875 .ToString()); 875 .ToString());
876 } 876 }
877 #endif // defined(OS_CHROMEOS) 877 #endif // defined(OS_CHROMEOS)
878 878
879 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 879 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
880 if (!SupportsMultipleDisplays()) 880 if (!SupportsMultipleDisplays())
881 return; 881 return;
882 882
883 const int64_t internal_display_id = 883 const int64_t internal_display_id =
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 display::Screen::GetScreen()->AddObserver(&display_observer); 1637 display::Screen::GetScreen()->AddObserver(&display_observer);
1638 1638
1639 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 1639 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1640 display_manager()->UpdateDisplays(); 1640 display_manager()->UpdateDisplays();
1641 RunAllPendingInMessageLoop(); 1641 RunAllPendingInMessageLoop();
1642 EXPECT_TRUE(display_observer.changed_and_reset()); 1642 EXPECT_TRUE(display_observer.changed_and_reset());
1643 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1643 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1644 EXPECT_EQ( 1644 EXPECT_EQ(
1645 "0,0 300x400", 1645 "0,0 300x400",
1646 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1646 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1647 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); 1647 EXPECT_EQ("400x500",
1648 test_api.GetHost()->GetBoundsInPixels().size().ToString());
1648 EXPECT_EQ("300x400", 1649 EXPECT_EQ("300x400",
1649 test_api.GetHost()->window()->bounds().size().ToString()); 1650 test_api.GetHost()->window()->bounds().size().ToString());
1650 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 1651 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1651 1652
1652 display_manager()->SetMirrorMode(false); 1653 display_manager()->SetMirrorMode(false);
1653 EXPECT_TRUE(display_observer.changed_and_reset()); 1654 EXPECT_TRUE(display_observer.changed_and_reset());
1654 EXPECT_EQ(nullptr, test_api.GetHost()); 1655 EXPECT_EQ(nullptr, test_api.GetHost());
1655 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 1656 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
1656 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 1657 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1657 1658
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 #if defined(OS_CHROMEOS) 1890 #if defined(OS_CHROMEOS)
1890 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) { 1891 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) {
1891 UpdateDisplay("100x200,300x400"); 1892 UpdateDisplay("100x200,300x400");
1892 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1893 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1893 aura::Window::Windows root_windows = 1894 aura::Window::Windows root_windows =
1894 Shell::GetInstance()->GetAllRootWindows(); 1895 Shell::GetInstance()->GetAllRootWindows();
1895 ASSERT_EQ(2U, root_windows.size()); 1896 ASSERT_EQ(2U, root_windows.size());
1896 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); 1897 aura::WindowTreeHost* host0 = root_windows[0]->GetHost();
1897 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); 1898 aura::WindowTreeHost* host1 = root_windows[1]->GetHost();
1898 1899
1899 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString()); 1900 EXPECT_EQ("1,1", host0->GetBoundsInPixels().origin().ToString());
1900 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1901 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
1901 // UpdateDisplay set the origin if it's not set. 1902 // UpdateDisplay set the origin if it's not set.
1902 EXPECT_NE("1,1", host1->GetBounds().origin().ToString()); 1903 EXPECT_NE("1,1", host1->GetBoundsInPixels().origin().ToString());
1903 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1904 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString());
1904 1905
1905 UpdateDisplay("100x200,200+300-300x400"); 1906 UpdateDisplay("100x200,200+300-300x400");
1906 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1907 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1907 EXPECT_EQ("0,0", host0->GetBounds().origin().ToString()); 1908 EXPECT_EQ("0,0", host0->GetBoundsInPixels().origin().ToString());
1908 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1909 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
1909 EXPECT_EQ("200,300", host1->GetBounds().origin().ToString()); 1910 EXPECT_EQ("200,300", host1->GetBoundsInPixels().origin().ToString());
1910 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1911 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString());
1911 1912
1912 UpdateDisplay("400+500-200x300,300x400"); 1913 UpdateDisplay("400+500-200x300,300x400");
1913 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1914 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1914 EXPECT_EQ("400,500", host0->GetBounds().origin().ToString()); 1915 EXPECT_EQ("400,500", host0->GetBoundsInPixels().origin().ToString());
1915 EXPECT_EQ("200x300", host0->GetBounds().size().ToString()); 1916 EXPECT_EQ("200x300", host0->GetBoundsInPixels().size().ToString());
1916 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); 1917 EXPECT_EQ("0,0", host1->GetBoundsInPixels().origin().ToString());
1917 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1918 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString());
1918 1919
1919 UpdateDisplay("100+200-100x200,300+500-200x300"); 1920 UpdateDisplay("100+200-100x200,300+500-200x300");
1920 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1921 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1921 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); 1922 EXPECT_EQ("100,200", host0->GetBoundsInPixels().origin().ToString());
1922 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1923 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
1923 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); 1924 EXPECT_EQ("300,500", host1->GetBoundsInPixels().origin().ToString());
1924 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); 1925 EXPECT_EQ("200x300", host1->GetBoundsInPixels().size().ToString());
1925 } 1926 }
1926 #endif // defined(OS_CHROMEOS) 1927 #endif // defined(OS_CHROMEOS)
1927 1928
1928 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) { 1929 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) {
1929 if (!SupportsMultipleDisplays()) 1930 if (!SupportsMultipleDisplays())
1930 return; 1931 return;
1931 1932
1932 // Don't check root window destruction in unified mode. 1933 // Don't check root window destruction in unified mode.
1933 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1934 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1934 1935
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 const display::DisplayLayout& stored = 2479 const display::DisplayLayout& stored =
2479 layout_store->GetRegisteredDisplayLayout(list); 2480 layout_store->GetRegisteredDisplayLayout(list);
2480 2481
2481 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2482 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2482 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2483 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2483 } 2484 }
2484 2485
2485 #endif // OS_CHROMEOS 2486 #endif // OS_CHROMEOS
2486 2487
2487 } // namespace ash 2488 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698