| 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" |
| 11 #include "ui/gfx/image/image.h" | 11 #include "ui/gfx/image/image.h" |
| 12 #include "ui/message_center/notification.h" | 12 #include "ui/message_center/notification.h" |
| 13 #include "ui/message_center/notification_list.h" | 13 #include "ui/message_center/notification_list.h" |
| 14 #include "ui/message_center/notification_types.h" | 14 #include "ui/message_center/notification_types.h" |
| 15 #include "ui/message_center/views/message_center_controller.h" | 15 #include "ui/message_center/views/message_center_controller.h" |
| 16 #include "ui/message_center/views/notification_button.h" | 16 #include "ui/message_center/views/notification_button.h" |
| 17 #include "ui/views/layout/fill_layout.h" | 17 #include "ui/views/layout/fill_layout.h" |
| 18 #include "ui/views/test/views_test_base.h" | 18 #include "ui/views/test/views_test_base.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 20 | 20 |
| 21 namespace message_center { | 21 namespace message_center { |
| 22 | 22 |
| 23 /* Test fixture ***************************************************************/ | 23 /* Test fixture ***************************************************************/ |
| 24 | 24 |
| 25 class NotificationViewTest : public views::ViewsTestBase, | 25 class NotificationViewTest : public views::ViewsTestBase, |
| 26 public MessageCenterController { | 26 public MessageCenterController { |
| 27 public: | 27 public: |
| 28 NotificationViewTest(); | 28 NotificationViewTest(); |
| 29 virtual ~NotificationViewTest(); | 29 ~NotificationViewTest() override; |
| 30 | 30 |
| 31 virtual void SetUp() override; | 31 void SetUp() override; |
| 32 virtual void TearDown() override; | 32 void TearDown() override; |
| 33 | 33 |
| 34 views::Widget* widget() { return notification_view_->GetWidget(); } | 34 views::Widget* widget() { return notification_view_->GetWidget(); } |
| 35 NotificationView* notification_view() { return notification_view_.get(); } | 35 NotificationView* notification_view() { return notification_view_.get(); } |
| 36 Notification* notification() { return notification_.get(); } | 36 Notification* notification() { return notification_.get(); } |
| 37 RichNotificationData* data() { return data_.get(); } | 37 RichNotificationData* data() { return data_.get(); } |
| 38 | 38 |
| 39 // Overridden from MessageCenterController: | 39 // Overridden from MessageCenterController: |
| 40 virtual void ClickOnNotification(const std::string& notification_id) override; | 40 void ClickOnNotification(const std::string& notification_id) override; |
| 41 virtual void RemoveNotification(const std::string& notification_id, | 41 void RemoveNotification(const std::string& notification_id, |
| 42 bool by_user) override; | 42 bool by_user) override; |
| 43 virtual scoped_ptr<ui::MenuModel> CreateMenuModel( | 43 scoped_ptr<ui::MenuModel> CreateMenuModel( |
| 44 const NotifierId& notifier_id, | 44 const NotifierId& notifier_id, |
| 45 const base::string16& display_source) override; | 45 const base::string16& display_source) override; |
| 46 virtual bool HasClickedListener(const std::string& notification_id) override; | 46 bool HasClickedListener(const std::string& notification_id) override; |
| 47 virtual void ClickOnNotificationButton(const std::string& notification_id, | 47 void ClickOnNotificationButton(const std::string& notification_id, |
| 48 int button_index) override; | 48 int button_index) override; |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 const gfx::Image CreateTestImage(int width, int height) { | 51 const gfx::Image CreateTestImage(int width, int height) { |
| 52 return gfx::Image::CreateFrom1xBitmap(CreateBitmap(width, height)); | 52 return gfx::Image::CreateFrom1xBitmap(CreateBitmap(width, height)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 const SkBitmap CreateBitmap(int width, int height) { | 55 const SkBitmap CreateBitmap(int width, int height) { |
| 56 SkBitmap bitmap; | 56 SkBitmap bitmap; |
| 57 bitmap.allocN32Pixels(width, height); | 57 bitmap.allocN32Pixels(width, height); |
| 58 bitmap.eraseRGB(0, 255, 0); | 58 bitmap.eraseRGB(0, 255, 0); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 // Double-check that vertical order is correct. | 324 // Double-check that vertical order is correct. |
| 325 CheckVerticalOrderInNotification(); | 325 CheckVerticalOrderInNotification(); |
| 326 | 326 |
| 327 // Tests that views remain in that order even after an update. | 327 // Tests that views remain in that order even after an update. |
| 328 UpdateNotificationViews(); | 328 UpdateNotificationViews(); |
| 329 CheckVerticalOrderInNotification(); | 329 CheckVerticalOrderInNotification(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace message_center | 332 } // namespace message_center |
| OLD | NEW |