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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: fix windows build Created 4 years, 1 month 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/browser/api/system_display/display_info_provider.h" 5 #include "extensions/browser/api/system_display/display_info_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/display/display_manager.h"
12 #include "ash/display/screen_orientation_controller_chromeos.h" 11 #include "ash/display/screen_orientation_controller_chromeos.h"
13 #include "ash/shell.h" 12 #include "ash/shell.h"
14 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
15 #include "ash/test/display_manager_test_api.h"
16 #include "base/command_line.h" 14 #include "base/command_line.h"
17 #include "base/macros.h" 15 #include "base/macros.h"
18 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
20 #include "extensions/common/api/system_display.h" 18 #include "extensions/common/api/system_display.h"
21 #include "ui/display/display.h" 19 #include "ui/display/display.h"
22 #include "ui/display/display_switches.h" 20 #include "ui/display/display_switches.h"
23 #include "ui/display/manager/display_layout.h" 21 #include "ui/display/manager/display_layout.h"
22 #include "ui/display/manager/display_manager.h"
23 #include "ui/display/test/display_manager_test_api.h"
24 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 25
26 namespace extensions { 26 namespace extensions {
27 namespace { 27 namespace {
28 28
29 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList; 29 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList;
30 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList; 30 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList;
31 31
32 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { 32 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase {
33 public: 33 public:
(...skipping 17 matching lines...) Expand all
51 (*error).clear(); 51 (*error).clear();
52 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); 52 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error);
53 } 53 }
54 54
55 bool DisplayExists(int64_t display_id) const { 55 bool DisplayExists(int64_t display_id) const {
56 const display::Display& display = 56 const display::Display& display =
57 GetDisplayManager()->GetDisplayForId(display_id); 57 GetDisplayManager()->GetDisplayForId(display_id);
58 return display.id() != display::Display::kInvalidDisplayID; 58 return display.id() != display::Display::kInvalidDisplayID;
59 } 59 }
60 60
61 ash::DisplayManager* GetDisplayManager() const { 61 display::DisplayManager* GetDisplayManager() const {
62 return ash::Shell::GetInstance()->display_manager(); 62 return ash::Shell::GetInstance()->display_manager();
63 } 63 }
64 64
65 std::string SystemInfoDisplayInsetsToString( 65 std::string SystemInfoDisplayInsetsToString(
66 const api::system_display::Insets& insets) const { 66 const api::system_display::Insets& insets) const {
67 // Order to match gfx::Insets::ToString(). 67 // Order to match gfx::Insets::ToString().
68 return base::StringPrintf( 68 return base::StringPrintf(
69 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); 69 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right);
70 } 70 }
71 71
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 ASSERT_EQ(2u, result.size()); 401 ASSERT_EQ(2u, result.size());
402 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); 402 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
403 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 403 EXPECT_TRUE(result[0].mirroring_source_id.empty());
404 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); 404 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id);
405 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 405 EXPECT_TRUE(result[1].mirroring_source_id.empty());
406 } 406 }
407 407
408 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { 408 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
409 UpdateDisplay("600x600, 400x520"); 409 UpdateDisplay("600x600, 400x520");
410 GetDisplayManager()->SetLayoutForCurrentDisplays( 410 GetDisplayManager()->SetLayoutForCurrentDisplays(
411 ash::test::CreateDisplayLayout(display_manager(), 411 display::test::CreateDisplayLayout(display_manager(),
412 display::DisplayPlacement::LEFT, -40)); 412 display::DisplayPlacement::LEFT, -40));
413 413
414 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 414 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
415 415
416 ASSERT_EQ(2u, result.size()); 416 ASSERT_EQ(2u, result.size());
417 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 417 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
418 EXPECT_EQ("-400,-40 400x520", 418 EXPECT_EQ("-400,-40 400x520",
419 SystemInfoDisplayBoundsToString(result[1].bounds)); 419 SystemInfoDisplayBoundsToString(result[1].bounds));
420 420
421 GetDisplayManager()->SetLayoutForCurrentDisplays( 421 GetDisplayManager()->SetLayoutForCurrentDisplays(
422 ash::test::CreateDisplayLayout(display_manager(), 422 display::test::CreateDisplayLayout(display_manager(),
423 display::DisplayPlacement::TOP, 40)); 423 display::DisplayPlacement::TOP, 40));
424 424
425 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 425 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
426 426
427 ASSERT_EQ(2u, result.size()); 427 ASSERT_EQ(2u, result.size());
428 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 428 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
429 EXPECT_EQ("40,-520 400x520", 429 EXPECT_EQ("40,-520 400x520",
430 SystemInfoDisplayBoundsToString(result[1].bounds)); 430 SystemInfoDisplayBoundsToString(result[1].bounds));
431 431
432 GetDisplayManager()->SetLayoutForCurrentDisplays( 432 GetDisplayManager()->SetLayoutForCurrentDisplays(
433 ash::test::CreateDisplayLayout(display_manager(), 433 display::test::CreateDisplayLayout(
434 display::DisplayPlacement::BOTTOM, 80)); 434 display_manager(), display::DisplayPlacement::BOTTOM, 80));
435 435
436 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 436 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
437 ASSERT_EQ(2u, result.size()); 437 ASSERT_EQ(2u, result.size());
438 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 438 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
439 EXPECT_EQ("80,600 400x520", 439 EXPECT_EQ("80,600 400x520",
440 SystemInfoDisplayBoundsToString(result[1].bounds)); 440 SystemInfoDisplayBoundsToString(result[1].bounds));
441 } 441 }
442 442
443 TEST_F(DisplayInfoProviderChromeosTest, Layout) { 443 TEST_F(DisplayInfoProviderChromeosTest, Layout) {
444 UpdateDisplay("500x400,500x400,500x400"); 444 UpdateDisplay("500x400,500x400,500x400");
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1113
1114 EXPECT_EQ(20, overscan.left()); 1114 EXPECT_EQ(20, overscan.left());
1115 EXPECT_EQ(199, overscan.top()); 1115 EXPECT_EQ(199, overscan.top());
1116 EXPECT_EQ(130, overscan.right()); 1116 EXPECT_EQ(130, overscan.right());
1117 EXPECT_EQ(51, overscan.bottom()); 1117 EXPECT_EQ(51, overscan.bottom());
1118 } 1118 }
1119 1119
1120 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { 1120 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) {
1121 UpdateDisplay("1200x600,600x1000*2"); 1121 UpdateDisplay("1200x600,600x1000*2");
1122 const int64_t internal_display_id = 1122 const int64_t internal_display_id =
1123 ash::test::DisplayManagerTestApi( 1123 display::test::DisplayManagerTestApi(
1124 ash::Shell::GetInstance()->display_manager()) 1124 ash::Shell::GetInstance()->display_manager())
1125 .SetFirstDisplayAsInternalDisplay(); 1125 .SetFirstDisplayAsInternalDisplay();
1126 1126
1127 api::system_display::DisplayProperties info; 1127 api::system_display::DisplayProperties info;
1128 info.overscan.reset(new api::system_display::Insets); 1128 info.overscan.reset(new api::system_display::Insets);
1129 // Vertical overscan is 501, which would make the bounds height 499. 1129 // Vertical overscan is 501, which would make the bounds height 499.
1130 info.overscan->left = 20; 1130 info.overscan->left = 20;
1131 info.overscan->top = 20; 1131 info.overscan->top = 20;
1132 info.overscan->right = 20; 1132 info.overscan->right = 20;
1133 info.overscan->bottom = 20; 1133 info.overscan->bottom = 20;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); 1190 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error);
1191 ASSERT_TRUE(success); 1191 ASSERT_TRUE(success);
1192 1192
1193 // Verify that other_mode now matches the active mode. 1193 // Verify that other_mode now matches the active mode.
1194 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); 1194 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id);
1195 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); 1195 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash));
1196 } 1196 }
1197 1197
1198 } // namespace 1198 } // namespace
1199 } // namespace extensions 1199 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/display_info_provider_chromeos.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698