| 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 "base/debug/leak_annotations.h" | 5 #include "base/debug/leak_annotations.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "extensions/browser/api/system_display/display_info_provider.h" | 7 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 8 #include "extensions/browser/api/system_display/system_display_api.h" | 8 #include "extensions/browser/api/system_display/system_display_api.h" |
| 9 #include "extensions/browser/api_test_utils.h" | 9 #include "extensions/browser/api_test_utils.h" |
| 10 #include "extensions/common/api/system_display.h" | 10 #include "extensions/common/api/system_display.h" |
| 11 #include "extensions/shell/test/shell_apitest.h" | 11 #include "extensions/shell/test/shell_apitest.h" |
| 12 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
| 13 #include "ui/gfx/display_observer.h" | 13 #include "ui/gfx/display_observer.h" |
| 14 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 | 17 |
| 18 using core_api::system_display::Bounds; | 18 using api::system_display::Bounds; |
| 19 using core_api::system_display::DisplayUnitInfo; | 19 using api::system_display::DisplayUnitInfo; |
| 20 using gfx::Screen; | 20 using gfx::Screen; |
| 21 | 21 |
| 22 class MockScreen : public Screen { | 22 class MockScreen : public Screen { |
| 23 public: | 23 public: |
| 24 MockScreen() { | 24 MockScreen() { |
| 25 for (int i = 0; i < 4; i++) { | 25 for (int i = 0; i < 4; i++) { |
| 26 gfx::Rect bounds(0, 0, 1280, 720); | 26 gfx::Rect bounds(0, 0, 1280, 720); |
| 27 gfx::Rect work_area(0, 0, 960, 720); | 27 gfx::Rect work_area(0, 0, 960, 720); |
| 28 gfx::Display display(i, bounds); | 28 gfx::Display display(i, bounds); |
| 29 display.set_work_area(work_area); | 29 display.set_work_area(work_area); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DISALLOW_COPY_AND_ASSIGN(MockScreen); | 66 DISALLOW_COPY_AND_ASSIGN(MockScreen); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class MockDisplayInfoProvider : public DisplayInfoProvider { | 69 class MockDisplayInfoProvider : public DisplayInfoProvider { |
| 70 public: | 70 public: |
| 71 MockDisplayInfoProvider() {} | 71 MockDisplayInfoProvider() {} |
| 72 | 72 |
| 73 ~MockDisplayInfoProvider() override {} | 73 ~MockDisplayInfoProvider() override {} |
| 74 | 74 |
| 75 bool SetInfo(const std::string& display_id, | 75 bool SetInfo(const std::string& display_id, |
| 76 const core_api::system_display::DisplayProperties& params, | 76 const api::system_display::DisplayProperties& params, |
| 77 std::string* error) override { | 77 std::string* error) override { |
| 78 // Should get called only once per test case. | 78 // Should get called only once per test case. |
| 79 EXPECT_FALSE(set_info_value_); | 79 EXPECT_FALSE(set_info_value_); |
| 80 set_info_value_ = params.ToValue(); | 80 set_info_value_ = params.ToValue(); |
| 81 set_info_display_id_ = display_id; | 81 set_info_display_id_ = display_id; |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 gfx::Screen* GetActiveScreen() override { return NULL; } | 85 gfx::Screen* GetActiveScreen() override { return NULL; } |
| 86 | 86 |
| 87 scoped_ptr<base::DictionaryValue> GetSetInfoValue() { | 87 scoped_ptr<base::DictionaryValue> GetSetInfoValue() { |
| 88 return set_info_value_.Pass(); | 88 return set_info_value_.Pass(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 std::string GetSetInfoDisplayId() const { return set_info_display_id_; } | 91 std::string GetSetInfoDisplayId() const { return set_info_display_id_; } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // Update the content of the |unit| obtained for |display| using | 94 // Update the content of the |unit| obtained for |display| using |
| 95 // platform specific method. | 95 // platform specific method. |
| 96 void UpdateDisplayUnitInfoForPlatform( | 96 void UpdateDisplayUnitInfoForPlatform( |
| 97 const gfx::Display& display, | 97 const gfx::Display& display, |
| 98 extensions::core_api::system_display::DisplayUnitInfo* unit) override { | 98 extensions::api::system_display::DisplayUnitInfo* unit) override { |
| 99 int64 id = display.id(); | 99 int64 id = display.id(); |
| 100 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id); | 100 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id); |
| 101 if (id == 1) | 101 if (id == 1) |
| 102 unit->mirroring_source_id = "0"; | 102 unit->mirroring_source_id = "0"; |
| 103 unit->is_primary = id == 0 ? true : false; | 103 unit->is_primary = id == 0 ? true : false; |
| 104 unit->is_internal = id == 0 ? true : false; | 104 unit->is_internal = id == 0 ? true : false; |
| 105 unit->is_enabled = true; | 105 unit->is_enabled = true; |
| 106 unit->rotation = (90 * id) % 360; | 106 unit->rotation = (90 * id) % 360; |
| 107 unit->dpi_x = 96.0; | 107 unit->dpi_x = 96.0; |
| 108 unit->dpi_y = 96.0; | 108 unit->dpi_y = 96.0; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 EXPECT_EQ(1, api_test_utils::GetInteger(overscan, "left")); | 242 EXPECT_EQ(1, api_test_utils::GetInteger(overscan, "left")); |
| 243 EXPECT_EQ(2, api_test_utils::GetInteger(overscan, "top")); | 243 EXPECT_EQ(2, api_test_utils::GetInteger(overscan, "top")); |
| 244 EXPECT_EQ(3, api_test_utils::GetInteger(overscan, "right")); | 244 EXPECT_EQ(3, api_test_utils::GetInteger(overscan, "right")); |
| 245 EXPECT_EQ(4, api_test_utils::GetInteger(overscan, "bottom")); | 245 EXPECT_EQ(4, api_test_utils::GetInteger(overscan, "bottom")); |
| 246 | 246 |
| 247 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); | 247 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); |
| 248 } | 248 } |
| 249 #endif // defined(OS_CHROMEOS) | 249 #endif // defined(OS_CHROMEOS) |
| 250 | 250 |
| 251 } // namespace extensions | 251 } // namespace extensions |
| OLD | NEW |