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

Side by Side Diff: chrome/test/base/view_event_test_base.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
« no previous file with comments | « chrome/test/base/view_event_test_base.h ('k') | components/infobars/core/infobar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/view_event_test_base.h" 5 #include "chrome/test/base/view_event_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // View subclass that allows you to specify the preferred size. 47 // View subclass that allows you to specify the preferred size.
48 class TestView : public views::View { 48 class TestView : public views::View {
49 public: 49 public:
50 TestView() {} 50 TestView() {}
51 51
52 void SetPreferredSize(const gfx::Size& size) { 52 void SetPreferredSize(const gfx::Size& size) {
53 preferred_size_ = size; 53 preferred_size_ = size;
54 PreferredSizeChanged(); 54 PreferredSizeChanged();
55 } 55 }
56 56
57 virtual gfx::Size GetPreferredSize() OVERRIDE { 57 virtual gfx::Size GetPreferredSize() const OVERRIDE {
58 if (!preferred_size_.IsEmpty()) 58 if (!preferred_size_.IsEmpty())
59 return preferred_size_; 59 return preferred_size_;
60 return View::GetPreferredSize(); 60 return View::GetPreferredSize();
61 } 61 }
62 62
63 virtual void Layout() OVERRIDE { 63 virtual void Layout() OVERRIDE {
64 View* child_view = child_at(0); 64 View* child_view = child_at(0);
65 child_view->SetBounds(0, 0, width(), height()); 65 child_view->SetBounds(0, 0, width(), height());
66 } 66 }
67 67
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 content::RunAllPendingInMessageLoop(); 221 content::RunAllPendingInMessageLoop();
222 222
223 // Schedule a task that starts the test. Need to do this as we're going to 223 // Schedule a task that starts the test. Need to do this as we're going to
224 // run the message loop. 224 // run the message loop.
225 base::MessageLoop::current()->PostTask( 225 base::MessageLoop::current()->PostTask(
226 FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); 226 FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this));
227 227
228 content::RunMessageLoop(); 228 content::RunMessageLoop();
229 } 229 }
230 230
231 gfx::Size ViewEventTestBase::GetPreferredSize() { 231 gfx::Size ViewEventTestBase::GetPreferredSize() const {
232 return gfx::Size(); 232 return gfx::Size();
233 } 233 }
234 234
235 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { 235 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) {
236 if (!dnd_thread_.get()) { 236 if (!dnd_thread_.get()) {
237 dnd_thread_.reset(new base::Thread("mouse-move-thread")); 237 dnd_thread_.reset(new base::Thread("mouse-move-thread"));
238 dnd_thread_->Start(); 238 dnd_thread_->Start();
239 } 239 }
240 dnd_thread_->message_loop()->PostDelayedTask( 240 dnd_thread_->message_loop()->PostDelayedTask(
241 FROM_HERE, 241 FROM_HERE,
242 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), 242 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y),
243 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); 243 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS));
244 } 244 }
245 245
246 void ViewEventTestBase::StopBackgroundThread() { 246 void ViewEventTestBase::StopBackgroundThread() {
247 dnd_thread_.reset(NULL); 247 dnd_thread_.reset(NULL);
248 } 248 }
249 249
250 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 250 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
251 StopBackgroundThread(); 251 StopBackgroundThread();
252 252
253 task.Run(); 253 task.Run();
254 if (HasFatalFailure()) 254 if (HasFatalFailure())
255 Done(); 255 Done();
256 } 256 }
OLDNEW
« no previous file with comments | « chrome/test/base/view_event_test_base.h ('k') | components/infobars/core/infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698