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

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: Add two more const for Windows. 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 (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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // View subclass that allows you to specify the preferred size. 46 // View subclass that allows you to specify the preferred size.
47 class TestView : public views::View { 47 class TestView : public views::View {
48 public: 48 public:
49 TestView() {} 49 TestView() {}
50 50
51 void SetPreferredSize(const gfx::Size& size) { 51 void SetPreferredSize(const gfx::Size& size) {
52 preferred_size_ = size; 52 preferred_size_ = size;
53 PreferredSizeChanged(); 53 PreferredSizeChanged();
54 } 54 }
55 55
56 virtual gfx::Size GetPreferredSize() OVERRIDE { 56 virtual gfx::Size GetPreferredSize() const OVERRIDE {
57 if (!preferred_size_.IsEmpty()) 57 if (!preferred_size_.IsEmpty())
58 return preferred_size_; 58 return preferred_size_;
59 return View::GetPreferredSize(); 59 return View::GetPreferredSize();
60 } 60 }
61 61
62 virtual void Layout() OVERRIDE { 62 virtual void Layout() OVERRIDE {
63 View* child_view = child_at(0); 63 View* child_view = child_at(0);
64 child_view->SetBounds(0, 0, width(), height()); 64 child_view->SetBounds(0, 0, width(), height());
65 } 65 }
66 66
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 content::RunAllPendingInMessageLoop(); 218 content::RunAllPendingInMessageLoop();
219 219
220 // Schedule a task that starts the test. Need to do this as we're going to 220 // Schedule a task that starts the test. Need to do this as we're going to
221 // run the message loop. 221 // run the message loop.
222 base::MessageLoop::current()->PostTask( 222 base::MessageLoop::current()->PostTask(
223 FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); 223 FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this));
224 224
225 content::RunMessageLoop(); 225 content::RunMessageLoop();
226 } 226 }
227 227
228 gfx::Size ViewEventTestBase::GetPreferredSize() { 228 gfx::Size ViewEventTestBase::GetPreferredSize() const {
229 return gfx::Size(); 229 return gfx::Size();
230 } 230 }
231 231
232 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { 232 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) {
233 if (!dnd_thread_.get()) { 233 if (!dnd_thread_.get()) {
234 dnd_thread_.reset(new base::Thread("mouse-move-thread")); 234 dnd_thread_.reset(new base::Thread("mouse-move-thread"));
235 dnd_thread_->Start(); 235 dnd_thread_->Start();
236 } 236 }
237 dnd_thread_->message_loop()->PostDelayedTask( 237 dnd_thread_->message_loop()->PostDelayedTask(
238 FROM_HERE, 238 FROM_HERE,
239 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), 239 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y),
240 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); 240 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS));
241 } 241 }
242 242
243 void ViewEventTestBase::StopBackgroundThread() { 243 void ViewEventTestBase::StopBackgroundThread() {
244 dnd_thread_.reset(NULL); 244 dnd_thread_.reset(NULL);
245 } 245 }
246 246
247 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 247 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
248 StopBackgroundThread(); 248 StopBackgroundThread();
249 249
250 task.Run(); 250 task.Run();
251 if (HasFatalFailure()) 251 if (HasFatalFailure())
252 Done(); 252 Done();
253 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698