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/utf_string_conversions.h" | 9 #include "base/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 public: | 33 public: |
34 virtual void RegisterCall(int receiver_id, CallType type) = 0; | 34 virtual void RegisterCall(int receiver_id, CallType type) = 0; |
35 }; | 35 }; |
36 | 36 |
37 explicit MockNotificationView(const Notification& notification, | 37 explicit MockNotificationView(const Notification& notification, |
38 MessageCenter* message_center, | 38 MessageCenter* message_center, |
39 Test* test, | 39 Test* test, |
40 int view_id); | 40 int view_id); |
41 virtual ~MockNotificationView(); | 41 virtual ~MockNotificationView(); |
42 | 42 |
43 virtual gfx::Size GetPreferredSize(); | 43 virtual gfx::Size GetPreferredSize() OVERRIDE; |
44 virtual int GetHeightForWidth(int w); | 44 virtual int GetHeightForWidth(int w) OVERRIDE; |
45 virtual void Layout(); | 45 virtual void Layout() OVERRIDE; |
46 | 46 |
47 int get_id() { return id_; }; | 47 int get_id() { return id_; }; |
48 | 48 |
49 private: | 49 private: |
50 void RegisterCall(CallType type); | 50 void RegisterCall(CallType type); |
51 | 51 |
52 Test* test_; | 52 Test* test_; |
53 int id_; | 53 int id_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(MockNotificationView); | 55 DISALLOW_COPY_AND_ASSIGN(MockNotificationView); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 MessageCenterViewTest(); | 97 MessageCenterViewTest(); |
98 virtual ~MessageCenterViewTest(); | 98 virtual ~MessageCenterViewTest(); |
99 | 99 |
100 virtual void SetUp() OVERRIDE; | 100 virtual void SetUp() OVERRIDE; |
101 virtual void TearDown() OVERRIDE; | 101 virtual void TearDown() OVERRIDE; |
102 | 102 |
103 MessageCenterView* GetMessageCenterView(); | 103 MessageCenterView* GetMessageCenterView(); |
104 int GetNotificationCount(); | 104 int GetNotificationCount(); |
105 int GetCallCount(CallType type); | 105 int GetCallCount(CallType type); |
106 | 106 |
107 void RegisterCall(int receiver_id, CallType type); | 107 virtual void RegisterCall(int receiver_id, CallType type) OVERRIDE; |
108 | 108 |
109 void LogBounds(int depth, views::View* view); | 109 void LogBounds(int depth, views::View* view); |
110 | 110 |
111 private: | 111 private: |
112 views::View* MakeParent(views::View* child1, views::View* child2); | 112 views::View* MakeParent(views::View* child1, views::View* child2); |
113 | 113 |
114 | 114 |
115 scoped_ptr<MessageCenterView> message_center_view_; | 115 scoped_ptr<MessageCenterView> message_center_view_; |
116 FakeMessageCenter message_center_; | 116 FakeMessageCenter message_center_; |
117 std::map<CallType,int> callCounts_; | 117 std::map<CallType,int> callCounts_; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very | 195 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very |
196 // large number corresponding to the current reality. That number will be | 196 // large number corresponding to the current reality. That number will be |
197 // ratcheted down over time as the code improves. | 197 // ratcheted down over time as the code improves. |
198 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2); | 198 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2); |
199 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) + | 199 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) + |
200 GetCallCount(GET_HEIGHT_FOR_WIDTH), | 200 GetCallCount(GET_HEIGHT_FOR_WIDTH), |
201 GetNotificationCount() * 20); | 201 GetNotificationCount() * 20); |
202 } | 202 } |
203 | 203 |
204 } // namespace message_center | 204 } // namespace message_center |
OLD | NEW |