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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/big_endian.h" | 8 #include "base/big_endian.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, | 466 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, |
467 SCALE_FACTOR_100P)); | 467 SCALE_FACTOR_100P)); |
468 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, | 468 EXPECT_EQ("this is id 6", resource_bundle->GetRawDataResourceForScale(6, |
469 SCALE_FACTOR_200P)); | 469 SCALE_FACTOR_200P)); |
470 } | 470 } |
471 | 471 |
472 // Test requesting image reps at various scale factors from the image returned | 472 // Test requesting image reps at various scale factors from the image returned |
473 // via ResourceBundle::GetImageNamed(). | 473 // via ResourceBundle::GetImageNamed(). |
474 TEST_F(ResourceBundleImageTest, GetImageNamed) { | 474 TEST_F(ResourceBundleImageTest, GetImageNamed) { |
475 #if defined(OS_WIN) | 475 #if defined(OS_WIN) |
476 gfx::ForceHighDPISupportForTesting(2.0); | 476 gfx::InitDeviceScaleFactor(2.0); |
477 #endif | 477 #endif |
478 std::vector<ScaleFactor> supported_factors; | 478 std::vector<ScaleFactor> supported_factors; |
479 supported_factors.push_back(SCALE_FACTOR_100P); | 479 supported_factors.push_back(SCALE_FACTOR_100P); |
480 supported_factors.push_back(SCALE_FACTOR_200P); | 480 supported_factors.push_back(SCALE_FACTOR_200P); |
481 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); | 481 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); |
482 base::FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak"); | 482 base::FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak"); |
483 base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak"); | 483 base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak"); |
484 | 484 |
485 // Create the pak files. | 485 // Create the pak files. |
486 CreateDataPackWithSingleBitmap(data_1x_path, 10, base::StringPiece()); | 486 CreateDataPackWithSingleBitmap(data_1x_path, 10, base::StringPiece()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); | 621 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); |
622 | 622 |
623 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); | 623 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); |
624 EXPECT_EQ(1u, image_skia->image_reps().size()); | 624 EXPECT_EQ(1u, image_skia->image_reps().size()); |
625 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); | 625 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); |
626 EXPECT_EQ(ui::SCALE_FACTOR_100P, | 626 EXPECT_EQ(ui::SCALE_FACTOR_100P, |
627 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); | 627 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); |
628 } | 628 } |
629 | 629 |
630 } // namespace ui | 630 } // namespace ui |
OLD | NEW |