OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/system_display/system_display_api.h" | 5 #include "chrome/browser/extensions/api/system_display/system_display_api.h" |
6 | 6 |
7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/extensions/api/system_display/display_info_provider.h" | 9 #include "chrome/browser/extensions/api/system_display/display_info_provider.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_function_test_utils.h" | 11 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 12 #include "chrome/common/extensions/api/system_display.h" |
12 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
13 #include "ui/gfx/display_observer.h" | 14 #include "ui/gfx/display_observer.h" |
14 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
15 | 16 |
16 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
17 #include "ash/display/screen_ash.h" | 18 #include "ash/display/screen_ash.h" |
18 #include "ash/shell.h" | 19 #include "ash/shell.h" |
19 #endif | 20 #endif |
20 | 21 |
21 namespace utils = extension_function_test_utils; | 22 namespace utils = extension_function_test_utils; |
(...skipping 22 matching lines...) Expand all Loading... |
44 // Overridden from gfx::Screen: | 45 // Overridden from gfx::Screen: |
45 virtual int GetNumDisplays() const OVERRIDE { | 46 virtual int GetNumDisplays() const OVERRIDE { |
46 return displays_.size(); | 47 return displays_.size(); |
47 } | 48 } |
48 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { | 49 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { |
49 return displays_; | 50 return displays_; |
50 } | 51 } |
51 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { | 52 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { |
52 return displays_[0]; | 53 return displays_[0]; |
53 } | 54 } |
| 55 |
54 private: | 56 private: |
55 std::vector<gfx::Display> displays_; | 57 std::vector<gfx::Display> displays_; |
56 | 58 |
57 DISALLOW_COPY_AND_ASSIGN(MockScreen); | 59 DISALLOW_COPY_AND_ASSIGN(MockScreen); |
58 }; | 60 }; |
59 #else | 61 #else |
60 class MockScreen : public Screen { | 62 class MockScreen : public Screen { |
61 public: | 63 public: |
62 MockScreen() { | 64 MockScreen() { |
63 for (int i = 0; i < 4; i++) { | 65 for (int i = 0; i < 4; i++) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 189 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
188 ash::Shell::GetScreen()); | 190 ash::Shell::GetScreen()); |
189 #endif | 191 #endif |
190 ExtensionApiTest::TearDownOnMainThread(); | 192 ExtensionApiTest::TearDownOnMainThread(); |
191 } | 193 } |
192 | 194 |
193 protected: | 195 protected: |
194 scoped_ptr<MockDisplayInfoProvider> provider_; | 196 scoped_ptr<MockDisplayInfoProvider> provider_; |
195 scoped_ptr<gfx::Screen> screen_; | 197 scoped_ptr<gfx::Screen> screen_; |
196 | 198 |
| 199 private: |
197 DISALLOW_COPY_AND_ASSIGN(SystemDisplayApiTest); | 200 DISALLOW_COPY_AND_ASSIGN(SystemDisplayApiTest); |
198 }; | 201 }; |
199 | 202 |
200 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, GetDisplay) { | 203 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, GetDisplay) { |
201 ASSERT_TRUE(RunPlatformAppTest("system/display")) << message_; | 204 ASSERT_TRUE(RunPlatformAppTest("system/display")) << message_; |
202 } | 205 } |
203 | 206 |
204 #if !defined(OS_CHROMEOS) | 207 #if !defined(OS_CHROMEOS) |
205 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplay) { | 208 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplay) { |
206 scoped_refptr<SystemDisplaySetDisplayPropertiesFunction> | 209 scoped_refptr<SystemDisplaySetDisplayPropertiesFunction> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 ASSERT_TRUE(set_info->GetDictionary("overscan", &overscan)); | 297 ASSERT_TRUE(set_info->GetDictionary("overscan", &overscan)); |
295 EXPECT_EQ(1, utils::GetInteger(overscan, "left")); | 298 EXPECT_EQ(1, utils::GetInteger(overscan, "left")); |
296 EXPECT_EQ(2, utils::GetInteger(overscan, "top")); | 299 EXPECT_EQ(2, utils::GetInteger(overscan, "top")); |
297 EXPECT_EQ(3, utils::GetInteger(overscan, "right")); | 300 EXPECT_EQ(3, utils::GetInteger(overscan, "right")); |
298 EXPECT_EQ(4, utils::GetInteger(overscan, "bottom")); | 301 EXPECT_EQ(4, utils::GetInteger(overscan, "bottom")); |
299 | 302 |
300 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); | 303 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); |
301 } | 304 } |
302 #endif // defined(OS_CHROMEOS) | 305 #endif // defined(OS_CHROMEOS) |
303 | 306 |
304 } // namespace extensions | 307 } // namespace extensions |
OLD | NEW |