| OLD | NEW |
| 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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/content/display/screen_orientation_controller_chromeos.h" | 8 #include "ash/content/display/screen_orientation_controller_chromeos.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/window_tree_host_manager.h" | 10 #include "ash/display/window_tree_host_manager.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 159 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 160 | 160 |
| 161 ASSERT_EQ(1u, result.size()); | 161 ASSERT_EQ(1u, result.size()); |
| 162 | 162 |
| 163 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); | 163 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); |
| 164 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 164 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 165 EXPECT_EQ(0, result[0]->rotation); | 165 EXPECT_EQ(0, result[0]->rotation); |
| 166 } | 166 } |
| 167 | 167 |
| 168 TEST_F(DisplayInfoProviderChromeosTest, GetHiDPI) { | 168 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) { |
| 169 UpdateDisplay("500x600,400x520*2"); | 169 UpdateDisplay("500x600,400x520*2"); |
| 170 DisplayInfo result; | 170 DisplayInfo result; |
| 171 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 171 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 172 | 172 |
| 173 ASSERT_EQ(2u, result.size()); | 173 ASSERT_EQ(2u, result.size()); |
| 174 | 174 |
| 175 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 175 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 176 EXPECT_EQ(96, result[0]->dpi_x); | 176 EXPECT_EQ(96, result[0]->dpi_x); |
| 177 EXPECT_EQ(96, result[0]->dpi_y); | 177 EXPECT_EQ(96, result[0]->dpi_y); |
| 178 | 178 |
| 179 EXPECT_EQ("500,0 200x260", | 179 EXPECT_EQ("500,0 200x260", |
| 180 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 180 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 181 EXPECT_EQ(2 * 96, result[1]->dpi_x); | 181 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale |
| 182 EXPECT_EQ(2 * 96, result[1]->dpi_y); | 182 // is 2. |
| 183 EXPECT_EQ(96 / 2, result[1]->dpi_x); |
| 184 EXPECT_EQ(96 / 2, result[1]->dpi_y); |
| 183 | 185 |
| 184 GetWindowTreeHostManager()->SwapPrimaryDisplay(); | 186 GetWindowTreeHostManager()->SwapPrimaryDisplay(); |
| 185 | 187 |
| 186 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 188 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 187 | 189 |
| 188 ASSERT_EQ(2u, result.size()); | 190 ASSERT_EQ(2u, result.size()); |
| 189 | 191 |
| 190 EXPECT_EQ("-500,0 500x600", | 192 EXPECT_EQ("-500,0 500x600", |
| 191 SystemInfoDisplayBoundsToString(result[0]->bounds)); | 193 SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 192 EXPECT_EQ(96, result[0]->dpi_x); | 194 EXPECT_EQ(96, result[0]->dpi_x); |
| 193 EXPECT_EQ(96, result[0]->dpi_y); | 195 EXPECT_EQ(96, result[0]->dpi_y); |
| 194 | 196 |
| 195 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds)); | 197 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 196 EXPECT_EQ(2 * 96, result[1]->dpi_x); | 198 EXPECT_EQ(96 / 2, result[1]->dpi_x); |
| 197 EXPECT_EQ(2 * 96, result[1]->dpi_y); | 199 EXPECT_EQ(96 / 2, result[1]->dpi_y); |
| 198 } | 200 } |
| 199 | 201 |
| 200 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { | 202 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { |
| 201 UpdateDisplay("640x720*2/o, 400x520/o"); | 203 UpdateDisplay("640x720*2/o, 400x520/o"); |
| 202 DisplayInfo result; | 204 DisplayInfo result; |
| 203 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 205 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 204 | 206 |
| 205 ASSERT_EQ(2u, result.size()); | 207 ASSERT_EQ(2u, result.size()); |
| 206 | 208 |
| 207 int64 display_id; | 209 int64 display_id; |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 std::string error; | 960 std::string error; |
| 959 CallSetDisplayUnitInfo( | 961 CallSetDisplayUnitInfo( |
| 960 base::Int64ToString(internal_display_id), info, &success, &error); | 962 base::Int64ToString(internal_display_id), info, &success, &error); |
| 961 | 963 |
| 962 ASSERT_FALSE(success); | 964 ASSERT_FALSE(success); |
| 963 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); | 965 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); |
| 964 } | 966 } |
| 965 | 967 |
| 966 } // namespace | 968 } // namespace |
| 967 } // namespace extensions | 969 } // namespace extensions |
| OLD | NEW |