| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 class Test { | 33 class Test { |
| 34 public: | 34 public: |
| 35 virtual void RegisterCall(CallType type) = 0; | 35 virtual void RegisterCall(CallType type) = 0; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 explicit MockNotificationView(MessageCenterController* controller, | 38 explicit MockNotificationView(MessageCenterController* controller, |
| 39 const Notification& notification, | 39 const Notification& notification, |
| 40 Test* test); | 40 Test* test); |
| 41 virtual ~MockNotificationView(); | 41 virtual ~MockNotificationView(); |
| 42 | 42 |
| 43 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 43 virtual gfx::Size GetPreferredSize() const override; |
| 44 virtual int GetHeightForWidth(int w) const OVERRIDE; | 44 virtual int GetHeightForWidth(int w) const override; |
| 45 virtual void Layout() OVERRIDE; | 45 virtual void Layout() override; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 Test* test_; | 48 Test* test_; |
| 49 | 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(MockNotificationView); | 50 DISALLOW_COPY_AND_ASSIGN(MockNotificationView); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 MockNotificationView::MockNotificationView(MessageCenterController* controller, | 53 MockNotificationView::MockNotificationView(MessageCenterController* controller, |
| 54 const Notification& notification, | 54 const Notification& notification, |
| 55 Test* test) | 55 Test* test) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 80 | 80 |
| 81 /* Test fixture ***************************************************************/ | 81 /* Test fixture ***************************************************************/ |
| 82 | 82 |
| 83 class MessageCenterViewTest : public testing::Test, | 83 class MessageCenterViewTest : public testing::Test, |
| 84 public MockNotificationView::Test, | 84 public MockNotificationView::Test, |
| 85 public MessageCenterController { | 85 public MessageCenterController { |
| 86 public: | 86 public: |
| 87 MessageCenterViewTest(); | 87 MessageCenterViewTest(); |
| 88 virtual ~MessageCenterViewTest(); | 88 virtual ~MessageCenterViewTest(); |
| 89 | 89 |
| 90 virtual void SetUp() OVERRIDE; | 90 virtual void SetUp() override; |
| 91 virtual void TearDown() OVERRIDE; | 91 virtual void TearDown() override; |
| 92 | 92 |
| 93 MessageCenterView* GetMessageCenterView(); | 93 MessageCenterView* GetMessageCenterView(); |
| 94 int GetNotificationCount(); | 94 int GetNotificationCount(); |
| 95 int GetCallCount(CallType type); | 95 int GetCallCount(CallType type); |
| 96 | 96 |
| 97 // Overridden from MessageCenterController: | 97 // Overridden from MessageCenterController: |
| 98 virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE; | 98 virtual void ClickOnNotification(const std::string& notification_id) override; |
| 99 virtual void RemoveNotification(const std::string& notification_id, | 99 virtual void RemoveNotification(const std::string& notification_id, |
| 100 bool by_user) OVERRIDE; | 100 bool by_user) override; |
| 101 virtual scoped_ptr<ui::MenuModel> CreateMenuModel( | 101 virtual scoped_ptr<ui::MenuModel> CreateMenuModel( |
| 102 const NotifierId& notifier_id, | 102 const NotifierId& notifier_id, |
| 103 const base::string16& display_source) OVERRIDE; | 103 const base::string16& display_source) override; |
| 104 virtual bool HasClickedListener(const std::string& notification_id) OVERRIDE; | 104 virtual bool HasClickedListener(const std::string& notification_id) override; |
| 105 virtual void ClickOnNotificationButton(const std::string& notification_id, | 105 virtual void ClickOnNotificationButton(const std::string& notification_id, |
| 106 int button_index) OVERRIDE; | 106 int button_index) override; |
| 107 | 107 |
| 108 // Overridden from MockNotificationView::Test | 108 // Overridden from MockNotificationView::Test |
| 109 virtual void RegisterCall(CallType type) OVERRIDE; | 109 virtual void RegisterCall(CallType type) override; |
| 110 | 110 |
| 111 void LogBounds(int depth, views::View* view); | 111 void LogBounds(int depth, views::View* view); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 views::View* MakeParent(views::View* child1, views::View* child2); | 114 views::View* MakeParent(views::View* child1, views::View* child2); |
| 115 | 115 |
| 116 | 116 |
| 117 scoped_ptr<MessageCenterView> message_center_view_; | 117 scoped_ptr<MessageCenterView> message_center_view_; |
| 118 FakeMessageCenter message_center_; | 118 FakeMessageCenter message_center_; |
| 119 std::map<CallType,int> callCounts_; | 119 std::map<CallType,int> callCounts_; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very | 233 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very |
| 234 // large number corresponding to the current reality. That number will be | 234 // large number corresponding to the current reality. That number will be |
| 235 // ratcheted down over time as the code improves. | 235 // ratcheted down over time as the code improves. |
| 236 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2); | 236 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2); |
| 237 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) + | 237 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) + |
| 238 GetCallCount(GET_HEIGHT_FOR_WIDTH), | 238 GetCallCount(GET_HEIGHT_FOR_WIDTH), |
| 239 GetNotificationCount() * 20); | 239 GetNotificationCount() * 20); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace message_center | 242 } // namespace message_center |
| OLD | NEW |