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/gfx/image/image_skia.h" | 5 #include "ui/gfx/image/image_skia.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/threading/simple_thread.h" | 8 #include "base/threading/simple_thread.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 EXPECT_TRUE(threadsafe_on_thread.can_read()); | 368 EXPECT_TRUE(threadsafe_on_thread.can_read()); |
369 EXPECT_FALSE(threadsafe_on_thread.can_modify()); | 369 EXPECT_FALSE(threadsafe_on_thread.can_modify()); |
370 EXPECT_TRUE(image.CanRead()); | 370 EXPECT_TRUE(image.CanRead()); |
371 EXPECT_FALSE(image.CanModify()); | 371 EXPECT_FALSE(image.CanModify()); |
372 } | 372 } |
373 #endif // ENABLE_NON_THREAD_SAFE | 373 #endif // ENABLE_NON_THREAD_SAFE |
374 | 374 |
375 // Just in case we ever get lumped together with other compilation units. | 375 // Just in case we ever get lumped together with other compilation units. |
376 #undef ENABLE_NON_THREAD_SAFE | 376 #undef ENABLE_NON_THREAD_SAFE |
377 | 377 |
| 378 TEST(ImageSkiaTest, Unscaled) { |
| 379 SkBitmap bitmap; |
| 380 |
| 381 // An ImageSkia created with 1x bitmap is unscaled. |
| 382 ImageSkia image_skia = ImageSkia::CreateFrom1xBitmap(bitmap); |
| 383 EXPECT_TRUE(image_skia.GetRepresentation(1.0f).unscaled()); |
| 384 ImageSkiaRep rep_2x(Size(100, 100), 2.0f); |
| 385 |
| 386 // When reps for other scales are added, the unscaled image |
| 387 // becomes scaled. |
| 388 image_skia.AddRepresentation(rep_2x); |
| 389 EXPECT_FALSE(image_skia.GetRepresentation(1.0f).unscaled()); |
| 390 EXPECT_FALSE(image_skia.GetRepresentation(2.0f).unscaled()); |
| 391 } |
| 392 |
378 } // namespace gfx | 393 } // namespace gfx |
OLD | NEW |