OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Paints |view| and returns the size that the original image (which must have | 93 // Paints |view| and returns the size that the original image (which must have |
94 // been created by CreateBitmap()) was scaled to. | 94 // been created by CreateBitmap()) was scaled to. |
95 gfx::Size GetImagePaintSize(ProportionalImageView* view) { | 95 gfx::Size GetImagePaintSize(ProportionalImageView* view) { |
96 CHECK(view); | 96 CHECK(view); |
97 if (view->bounds().IsEmpty()) | 97 if (view->bounds().IsEmpty()) |
98 return gfx::Size(); | 98 return gfx::Size(); |
99 | 99 |
100 gfx::Size canvas_size = view->bounds().size(); | 100 gfx::Size canvas_size = view->bounds().size(); |
101 gfx::Canvas canvas(canvas_size, 1.0 /* image_scale */, | 101 gfx::Canvas canvas(canvas_size, 1.0 /* image_scale */, |
102 true /* is_opaque */); | 102 true /* is_opaque */); |
103 COMPILE_ASSERT(kBitmapColor != SK_ColorBLACK, | 103 static_assert(kBitmapColor != SK_ColorBLACK, |
104 bitmap_color_matches_background_color); | 104 "The bitmap color must match the background color"); |
105 canvas.DrawColor(SK_ColorBLACK); | 105 canvas.DrawColor(SK_ColorBLACK); |
106 view->OnPaint(&canvas); | 106 view->OnPaint(&canvas); |
107 | 107 |
108 SkBitmap bitmap; | 108 SkBitmap bitmap; |
109 bitmap.allocN32Pixels(canvas_size.width(), canvas_size.height()); | 109 bitmap.allocN32Pixels(canvas_size.width(), canvas_size.height()); |
110 canvas.sk_canvas()->readPixels(&bitmap, 0, 0); | 110 canvas.sk_canvas()->readPixels(&bitmap, 0, 0); |
111 | 111 |
112 // Incrementally inset each edge at its midpoint to find the bounds of the | 112 // Incrementally inset each edge at its midpoint to find the bounds of the |
113 // rect containing the image's color. This assumes that the image is | 113 // rect containing the image's color. This assumes that the image is |
114 // centered in the canvas. | 114 // centered in the canvas. |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // The url has been elided (it starts with an ellipsis) | 611 // The url has been elided (it starts with an ellipsis) |
612 // The end of the domainsuffix is shown | 612 // The end of the domainsuffix is shown |
613 // the url piece is not shown | 613 // the url piece is not shown |
614 EXPECT_TRUE(base::UTF16ToUTF8(result).find( | 614 EXPECT_TRUE(base::UTF16ToUTF8(result).find( |
615 ".veryveryveyrylong.chromium.org") != std::string::npos); | 615 ".veryveryveyrylong.chromium.org") != std::string::npos); |
616 EXPECT_TRUE(base::UTF16ToUTF8(result).find("\xE2\x80\xA6") == 0); | 616 EXPECT_TRUE(base::UTF16ToUTF8(result).find("\xE2\x80\xA6") == 0); |
617 EXPECT_TRUE(base::UTF16ToUTF8(result).find("hello") == std::string::npos); | 617 EXPECT_TRUE(base::UTF16ToUTF8(result).find("hello") == std::string::npos); |
618 } | 618 } |
619 | 619 |
620 } // namespace message_center | 620 } // namespace message_center |
OLD | NEW |