| 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "ui/base/layout.h" | 23 #include "ui/base/layout.h" |
| 24 #include "ui/base/resource/data_pack.h" | 24 #include "ui/base/resource/data_pack.h" |
| 25 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
| 26 #include "ui/gfx/font_list.h" | 26 #include "ui/gfx/font_list.h" |
| 27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
| 28 #include "ui/resources/grit/ui_resources.h" | 28 #include "ui/resources/grit/ui_resources.h" |
| 29 #include "ui/strings/grit/app_locale_settings.h" | 29 #include "ui/strings/grit/app_locale_settings.h" |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 #include "ui/gfx/win/dpi.h" | 32 #include "ui/display/win/dpi.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using ::testing::_; | 35 using ::testing::_; |
| 36 using ::testing::Between; | 36 using ::testing::Between; |
| 37 using ::testing::Property; | 37 using ::testing::Property; |
| 38 using ::testing::Return; | 38 using ::testing::Return; |
| 39 using ::testing::ReturnArg; | 39 using ::testing::ReturnArg; |
| 40 | 40 |
| 41 namespace ui { | 41 namespace ui { |
| 42 | 42 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, | 454 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, |
| 455 SCALE_FACTOR_100P)); | 455 SCALE_FACTOR_100P)); |
| 456 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, | 456 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, |
| 457 SCALE_FACTOR_200P)); | 457 SCALE_FACTOR_200P)); |
| 458 } | 458 } |
| 459 | 459 |
| 460 // Test requesting image reps at various scale factors from the image returned | 460 // Test requesting image reps at various scale factors from the image returned |
| 461 // via ResourceBundle::GetImageNamed(). | 461 // via ResourceBundle::GetImageNamed(). |
| 462 TEST_F(ResourceBundleImageTest, GetImageNamed) { | 462 TEST_F(ResourceBundleImageTest, GetImageNamed) { |
| 463 #if defined(OS_WIN) | 463 #if defined(OS_WIN) |
| 464 gfx::SetDefaultDeviceScaleFactor(2.0); | 464 display::win::SetDefaultDeviceScaleFactor(2.0); |
| 465 #endif | 465 #endif |
| 466 std::vector<ScaleFactor> supported_factors; | 466 std::vector<ScaleFactor> supported_factors; |
| 467 supported_factors.push_back(SCALE_FACTOR_100P); | 467 supported_factors.push_back(SCALE_FACTOR_100P); |
| 468 supported_factors.push_back(SCALE_FACTOR_200P); | 468 supported_factors.push_back(SCALE_FACTOR_200P); |
| 469 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); | 469 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); |
| 470 base::FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak"); | 470 base::FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak"); |
| 471 base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak"); | 471 base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak"); |
| 472 | 472 |
| 473 // Create the pak files. | 473 // Create the pak files. |
| 474 CreateDataPackWithSingleBitmap(data_1x_path, 10, base::StringPiece()); | 474 CreateDataPackWithSingleBitmap(data_1x_path, 10, base::StringPiece()); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); | 704 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); |
| 705 | 705 |
| 706 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); | 706 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); |
| 707 EXPECT_EQ(1u, image_skia->image_reps().size()); | 707 EXPECT_EQ(1u, image_skia->image_reps().size()); |
| 708 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); | 708 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); |
| 709 EXPECT_EQ(ui::SCALE_FACTOR_100P, | 709 EXPECT_EQ(ui::SCALE_FACTOR_100P, |
| 710 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); | 710 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); |
| 711 } | 711 } |
| 712 | 712 |
| 713 } // namespace ui | 713 } // namespace ui |
| OLD | NEW |