Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/command_line.h" | |
| 5 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
| 6 #include "base/macros.h" | 7 #include "base/macros.h" |
| 7 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/extensions/extension_icon_manager.h" | 14 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 16 #include "components/crx_file/id_util.h" | 17 #include "components/crx_file/id_util.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 18 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "ui/base/layout.h" | 21 #include "ui/base/layout.h" |
| 22 #include "ui/display/display_switches.h" | |
| 23 #include "ui/display/test/test_screen.h" | |
| 21 #include "ui/gfx/favicon_size.h" | 24 #include "ui/gfx/favicon_size.h" |
| 22 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 26 #include "ui/gfx/image/image_skia.h" |
| 24 #include "ui/gfx/image/image_unittest_util.h" | 27 #include "ui/gfx/image/image_unittest_util.h" |
| 25 #include "ui/gfx/skia_util.h" | 28 #include "ui/gfx/skia_util.h" |
| 26 | 29 |
| 27 namespace extensions { | 30 namespace extensions { |
| 28 namespace { | 31 namespace { |
| 29 | 32 |
| 30 using content::BrowserThread; | 33 using content::BrowserThread; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 scale_factor_iter < ui::NUM_SCALE_FACTORS; ++scale_factor_iter) { | 264 scale_factor_iter < ui::NUM_SCALE_FACTORS; ++scale_factor_iter) { |
| 262 auto scale_factor = static_cast<ui::ScaleFactor>(scale_factor_iter); | 265 auto scale_factor = static_cast<ui::ScaleFactor>(scale_factor_iter); |
| 263 float scale = ui::GetScaleForScaleFactor(scale_factor); | 266 float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 264 SCOPED_TRACE(testing::Message() << "Scale: " << scale); | 267 SCOPED_TRACE(testing::Message() << "Scale: " << scale); |
| 265 | 268 |
| 266 const bool has_representation = image_skia.HasRepresentation(scale); | 269 const bool has_representation = image_skia.HasRepresentation(scale); |
| 267 // We shouldn't have a representation if the extension didn't provide a | 270 // We shouldn't have a representation if the extension didn't provide a |
| 268 // big enough icon. | 271 // big enough icon. |
| 269 if (gfx::kFaviconSize * scale > kMaxIconSizeInManifest) | 272 if (gfx::kFaviconSize * scale > kMaxIconSizeInManifest) |
| 270 EXPECT_FALSE(has_representation); | 273 EXPECT_FALSE(has_representation); |
| 271 else | 274 else if (ui::IsSupportedScale(scale)) |
|
Devlin
2017/01/09 21:58:33
if it's *not* a supported scale, can we assert tha
Devlin
2017/01/13 15:53:47
ping on this one
Evan Stade
2017/01/17 19:07:11
sorry for not responding. I reverted this change.
| |
| 272 EXPECT_EQ(ui::IsSupportedScale(scale), has_representation); | 275 EXPECT_TRUE(has_representation); |
| 273 } | 276 } |
| 274 } | 277 } |
| 278 | |
| 279 // Now check that the DSFs for active displays are respected. | |
| 280 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 281 switches::kForceDeviceScaleFactor, "1.5"); | |
| 282 display::test::TestScreen test_screen; | |
| 283 display::Screen::SetScreenInstance(&test_screen); | |
| 284 TestIconManager icon_manager(this); | |
| 285 | |
| 286 icon_manager.LoadIcon(profile.get(), extension.get()); | |
| 287 WaitForImageLoad(); | |
| 288 gfx::ImageSkia icon = icon_manager.GetIcon(extension->id()).AsImageSkia(); | |
| 289 EXPECT_TRUE(icon.HasRepresentation(1.5f)); | |
| 290 display::Screen::SetScreenInstance(nullptr); | |
| 275 } | 291 } |
| 276 | 292 |
| 277 } // namespace | 293 } // namespace |
| 278 } // namespace extensions | 294 } // namespace extensions |
| OLD | NEW |