Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ui/base/resource/resource_bundle_unittest.cc

Issue 326073005: Enable arbitrary scale factor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 GetScaleForScaleFactor(ui::SCALE_FACTOR_200P)); 485 GetScaleForScaleFactor(ui::SCALE_FACTOR_200P));
486 EXPECT_EQ(ui::SCALE_FACTOR_200P, GetSupportedScaleFactor(image_rep.scale())); 486 EXPECT_EQ(ui::SCALE_FACTOR_200P, GetSupportedScaleFactor(image_rep.scale()));
487 487
488 // The 1.4x pack was not loaded. Requesting the 1.4x resource should return 488 // The 1.4x pack was not loaded. Requesting the 1.4x resource should return
489 // either the 1x or the 2x resource. 489 // either the 1x or the 2x resource.
490 image_rep = image_skia->GetRepresentation( 490 image_rep = image_skia->GetRepresentation(
491 ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_140P)); 491 ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_140P));
492 ui::ScaleFactor scale_factor = GetSupportedScaleFactor(image_rep.scale()); 492 ui::ScaleFactor scale_factor = GetSupportedScaleFactor(image_rep.scale());
493 EXPECT_TRUE(scale_factor == ui::SCALE_FACTOR_100P || 493 EXPECT_TRUE(scale_factor == ui::SCALE_FACTOR_100P ||
494 scale_factor == ui::SCALE_FACTOR_200P); 494 scale_factor == ui::SCALE_FACTOR_200P);
495 #if !defined(OS_WIN) 495
496 // If the image is not found, the it should simply image rep should 496 // ImageSkia scales image if the one for the requested scale factor is not
497 // contain the scale of the image rep, not the requested scale. 497 // available.
498 EXPECT_EQ(1.0f, image_skia->GetRepresentation(1.4f).scale()); 498 EXPECT_EQ(1.4f, image_skia->GetRepresentation(1.4f).scale());
499 #endif
500 } 499 }
501 500
502 // Test that GetImageNamed() behaves properly for images which GRIT has 501 // Test that GetImageNamed() behaves properly for images which GRIT has
503 // annotated as having fallen back to 1x. 502 // annotated as having fallen back to 1x.
504 TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) { 503 TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
505 std::vector<ScaleFactor> supported_factors; 504 std::vector<ScaleFactor> supported_factors;
506 supported_factors.push_back(SCALE_FACTOR_100P); 505 supported_factors.push_back(SCALE_FACTOR_100P);
507 supported_factors.push_back(SCALE_FACTOR_200P); 506 supported_factors.push_back(SCALE_FACTOR_200P);
508 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); 507 test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
509 base::FilePath data_path = dir_path().AppendASCII("sample.pak"); 508 base::FilePath data_path = dir_path().AppendASCII("sample.pak");
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 591 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
593 592
594 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 593 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
595 EXPECT_EQ(1u, image_skia->image_reps().size()); 594 EXPECT_EQ(1u, image_skia->image_reps().size());
596 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); 595 EXPECT_TRUE(image_skia->image_reps()[0].unscaled());
597 EXPECT_EQ(ui::SCALE_FACTOR_100P, 596 EXPECT_EQ(ui::SCALE_FACTOR_100P,
598 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); 597 GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
599 } 598 }
600 599
601 } // namespace ui 600 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698