Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: ui/message_center/views/message_center_view_unittest.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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() OVERRIDE; 43 virtual gfx::Size GetPreferredSize() const OVERRIDE;
44 virtual int GetHeightForWidth(int w) 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)
56 : NotificationView(controller, notification), 56 : NotificationView(controller, notification),
57 test_(test) { 57 test_(test) {
58 } 58 }
59 59
60 MockNotificationView::~MockNotificationView() { 60 MockNotificationView::~MockNotificationView() {
61 } 61 }
62 62
63 gfx::Size MockNotificationView::GetPreferredSize() { 63 gfx::Size MockNotificationView::GetPreferredSize() const {
64 test_->RegisterCall(GET_PREFERRED_SIZE); 64 test_->RegisterCall(GET_PREFERRED_SIZE);
65 DCHECK(child_count() > 0); 65 DCHECK(child_count() > 0);
66 return NotificationView::GetPreferredSize(); 66 return NotificationView::GetPreferredSize();
67 } 67 }
68 68
69 int MockNotificationView::GetHeightForWidth(int width) { 69 int MockNotificationView::GetHeightForWidth(int width) const {
70 test_->RegisterCall(GET_HEIGHT_FOR_WIDTH); 70 test_->RegisterCall(GET_HEIGHT_FOR_WIDTH);
71 DCHECK(child_count() > 0); 71 DCHECK(child_count() > 0);
72 return NotificationView::GetHeightForWidth(width); 72 return NotificationView::GetHeightForWidth(width);
73 } 73 }
74 74
75 void MockNotificationView::Layout() { 75 void MockNotificationView::Layout() {
76 test_->RegisterCall(LAYOUT); 76 test_->RegisterCall(LAYOUT);
77 DCHECK(child_count() > 0); 77 DCHECK(child_count() > 0);
78 NotificationView::Layout(); 78 NotificationView::Layout();
79 } 79 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very 232 // GetHeightForWidth() calls per descendant NotificationView. 20 is a very
233 // large number corresponding to the current reality. That number will be 233 // large number corresponding to the current reality. That number will be
234 // ratcheted down over time as the code improves. 234 // ratcheted down over time as the code improves.
235 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2); 235 EXPECT_LE(GetCallCount(LAYOUT), GetNotificationCount() * 2);
236 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) + 236 EXPECT_LE(GetCallCount(GET_PREFERRED_SIZE) +
237 GetCallCount(GET_HEIGHT_FOR_WIDTH), 237 GetCallCount(GET_HEIGHT_FOR_WIDTH),
238 GetNotificationCount() * 20); 238 GetNotificationCount() * 20);
239 } 239 }
240 240
241 } // namespace message_center 241 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view.cc ('k') | ui/message_center/views/notification_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698