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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
15 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
16 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_processor.h" |
17 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 base::UTF8ToUTF16(""), CreateTestImage(80, 80), base::UTF8ToUTF16(""), | 635 base::UTF8ToUTF16(""), CreateTestImage(80, 80), base::UTF8ToUTF16(""), |
635 GURL(kLongUrlContext), message_center::NotifierId(GURL()), *data(), NULL); | 636 GURL(kLongUrlContext), message_center::NotifierId(GURL()), *data(), NULL); |
636 notification4.set_context_message(base::ASCIIToUTF16("")); | 637 notification4.set_context_message(base::ASCIIToUTF16("")); |
637 result = notification_view()->FormatContextMessage(notification4); | 638 result = notification_view()->FormatContextMessage(notification4); |
638 | 639 |
639 // Different platforms elide at different lengths so we do | 640 // Different platforms elide at different lengths so we do |
640 // some generic checking here. | 641 // some generic checking here. |
641 // The url has been elided (it starts with an ellipsis) | 642 // The url has been elided (it starts with an ellipsis) |
642 // The end of the domainsuffix is shown | 643 // The end of the domainsuffix is shown |
643 // the url piece is not shown | 644 // the url piece is not shown |
644 EXPECT_TRUE(base::UTF16ToUTF8(result).find( | 645 std::string result_utf8 = base::UTF16ToUTF8(result); |
645 ".veryveryveyrylong.chromium.org") != std::string::npos); | 646 EXPECT_TRUE(result_utf8.find(".veryveryveyrylong.chromium.org") != |
646 EXPECT_TRUE(base::UTF16ToUTF8(result).find("\xE2\x80\xA6") == 0); | 647 std::string::npos); |
647 EXPECT_TRUE(base::UTF16ToUTF8(result).find("hello") == std::string::npos); | 648 EXPECT_TRUE(base::StartsWith(result_utf8, "\xE2\x80\xA6", |
| 649 base::CompareCase::SENSITIVE)); |
| 650 EXPECT_TRUE(result_utf8.find("hello") == std::string::npos); |
648 } | 651 } |
649 | 652 |
650 TEST_F(NotificationViewTest, SlideOut) { | 653 TEST_F(NotificationViewTest, SlideOut) { |
651 ui::ScopedAnimationDurationScaleMode zero_duration_scope( | 654 ui::ScopedAnimationDurationScaleMode zero_duration_scope( |
652 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 655 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
653 | 656 |
654 UpdateNotificationViews(); | 657 UpdateNotificationViews(); |
655 std::string notification_id = notification()->id(); | 658 std::string notification_id = notification()->id(); |
656 | 659 |
657 auto event_begin = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN); | 660 auto event_begin = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 TEST_F(NotificationViewTest, Pinned) { | 704 TEST_F(NotificationViewTest, Pinned) { |
702 notification()->set_pinned(true); | 705 notification()->set_pinned(true); |
703 | 706 |
704 UpdateNotificationViews(); | 707 UpdateNotificationViews(); |
705 EXPECT_EQ(NULL, GetCloseButton()); | 708 EXPECT_EQ(NULL, GetCloseButton()); |
706 } | 709 } |
707 | 710 |
708 #endif // defined(OS_CHROMEOS) | 711 #endif // defined(OS_CHROMEOS) |
709 | 712 |
710 } // namespace message_center | 713 } // namespace message_center |
OLD | NEW |