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

Side by Side Diff: mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc

Issue 634483003: replace OVERRIDE and FINAL with override and final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove compiler_specific.h inclusions Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/view_manager.h" 5 #include "mojo/services/public/cpp/view_manager/view_manager.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/application_manager/application_manager.h" 10 #include "mojo/application_manager/application_manager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 private: 54 private:
55 // Overridden from ApplicationDelegate: 55 // Overridden from ApplicationDelegate:
56 virtual void Initialize(ApplicationImpl* app) override { 56 virtual void Initialize(ApplicationImpl* app) override {
57 view_manager_client_factory_.reset( 57 view_manager_client_factory_.reset(
58 new ViewManagerClientFactory(app->shell(), this)); 58 new ViewManagerClientFactory(app->shell(), this));
59 } 59 }
60 60
61 // Overridden from ApplicationLoader: 61 // Overridden from ApplicationLoader:
62 virtual void Load(ApplicationManager* manager, 62 virtual void Load(ApplicationManager* manager,
63 const GURL& url, 63 const GURL& url,
64 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE { 64 scoped_refptr<LoadCallbacks> callbacks) override {
65 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication(); 65 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication();
66 if (!shell_handle.is_valid()) 66 if (!shell_handle.is_valid())
67 return; 67 return;
68 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, 68 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this,
69 shell_handle.Pass())); 69 shell_handle.Pass()));
70 apps_.push_back(app.release()); 70 apps_.push_back(app.release());
71 } 71 }
72 72
73 virtual void OnApplicationError(ApplicationManager* manager, 73 virtual void OnApplicationError(ApplicationManager* manager,
74 const GURL& url) OVERRIDE {} 74 const GURL& url) override {}
75 75
76 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 76 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
77 OVERRIDE { 77 override {
78 connection->AddService(view_manager_client_factory_.get()); 78 connection->AddService(view_manager_client_factory_.get());
79 return true; 79 return true;
80 } 80 }
81 81
82 // Overridden from ViewManagerDelegate: 82 // Overridden from ViewManagerDelegate:
83 virtual void OnEmbed(ViewManager* view_manager, 83 virtual void OnEmbed(ViewManager* view_manager,
84 View* root, 84 View* root,
85 ServiceProviderImpl* exported_services, 85 ServiceProviderImpl* exported_services,
86 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { 86 scoped_ptr<ServiceProvider> imported_services) override {
87 callback_.Run(view_manager, root); 87 callback_.Run(view_manager, root);
88 } 88 }
89 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {} 89 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {}
90 90
91 ScopedVector<ApplicationImpl> apps_; 91 ScopedVector<ApplicationImpl> apps_;
92 LoadedCallback callback_; 92 LoadedCallback callback_;
93 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; 93 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(ConnectApplicationLoader); 95 DISALLOW_COPY_AND_ASSIGN(ConnectApplicationLoader);
96 }; 96 };
97 97
98 class BoundsChangeObserver : public ViewObserver { 98 class BoundsChangeObserver : public ViewObserver {
99 public: 99 public:
100 explicit BoundsChangeObserver(View* view) : view_(view) {} 100 explicit BoundsChangeObserver(View* view) : view_(view) {}
101 virtual ~BoundsChangeObserver() {} 101 virtual ~BoundsChangeObserver() {}
102 102
103 private: 103 private:
104 // Overridden from ViewObserver: 104 // Overridden from ViewObserver:
105 virtual void OnViewBoundsChanged(View* view, 105 virtual void OnViewBoundsChanged(View* view,
106 const gfx::Rect& old_bounds, 106 const gfx::Rect& old_bounds,
107 const gfx::Rect& new_bounds) OVERRIDE { 107 const gfx::Rect& new_bounds) override {
108 DCHECK_EQ(view, view_); 108 DCHECK_EQ(view, view_);
109 QuitRunLoop(); 109 QuitRunLoop();
110 } 110 }
111 111
112 View* view_; 112 View* view_;
113 113
114 DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver); 114 DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
115 }; 115 };
116 116
117 // Wait until the bounds of the supplied view change. 117 // Wait until the bounds of the supplied view change.
(...skipping 12 matching lines...) Expand all
130 : tree_(tree), 130 : tree_(tree),
131 tree_size_(tree_size) {} 131 tree_size_(tree_size) {}
132 virtual ~TreeSizeMatchesObserver() {} 132 virtual ~TreeSizeMatchesObserver() {}
133 133
134 bool IsTreeCorrectSize() { 134 bool IsTreeCorrectSize() {
135 return CountViews(tree_) == tree_size_; 135 return CountViews(tree_) == tree_size_;
136 } 136 }
137 137
138 private: 138 private:
139 // Overridden from ViewObserver: 139 // Overridden from ViewObserver:
140 virtual void OnTreeChanged(const TreeChangeParams& params) OVERRIDE { 140 virtual void OnTreeChanged(const TreeChangeParams& params) override {
141 if (IsTreeCorrectSize()) 141 if (IsTreeCorrectSize())
142 QuitRunLoop(); 142 QuitRunLoop();
143 } 143 }
144 144
145 size_t CountViews(const View* view) const { 145 size_t CountViews(const View* view) const {
146 size_t count = 1; 146 size_t count = 1;
147 View::Children::const_iterator it = view->children().begin(); 147 View::Children::const_iterator it = view->children().begin();
148 for (; it != view->children().end(); ++it) 148 for (; it != view->children().end(); ++it)
149 count += CountViews(*it); 149 count += CountViews(*it);
150 return count; 150 return count;
(...skipping 16 matching lines...) Expand all
167 167
168 // Utility class that waits for the destruction of some number of views and 168 // Utility class that waits for the destruction of some number of views and
169 // views. 169 // views.
170 class DestructionObserver : public ViewObserver { 170 class DestructionObserver : public ViewObserver {
171 public: 171 public:
172 // |views| or |views| can be NULL. 172 // |views| or |views| can be NULL.
173 explicit DestructionObserver(std::set<Id>* views) : views_(views) {} 173 explicit DestructionObserver(std::set<Id>* views) : views_(views) {}
174 174
175 private: 175 private:
176 // Overridden from ViewObserver: 176 // Overridden from ViewObserver:
177 virtual void OnViewDestroyed(View* view) OVERRIDE { 177 virtual void OnViewDestroyed(View* view) override {
178 std::set<Id>::iterator it = views_->find(view->id()); 178 std::set<Id>::iterator it = views_->find(view->id());
179 if (it != views_->end()) 179 if (it != views_->end())
180 views_->erase(it); 180 views_->erase(it);
181 if (CanQuit()) 181 if (CanQuit())
182 QuitRunLoop(); 182 QuitRunLoop();
183 } 183 }
184 184
185 bool CanQuit() { 185 bool CanQuit() {
186 return !views_ || views_->empty(); 186 return !views_ || views_->empty();
187 } 187 }
(...skipping 21 matching lines...) Expand all
209 view_->AddObserver(this); 209 view_->AddObserver(this);
210 } 210 }
211 virtual ~OrderChangeObserver() { 211 virtual ~OrderChangeObserver() {
212 view_->RemoveObserver(this); 212 view_->RemoveObserver(this);
213 } 213 }
214 214
215 private: 215 private:
216 // Overridden from ViewObserver: 216 // Overridden from ViewObserver:
217 virtual void OnViewReordered(View* view, 217 virtual void OnViewReordered(View* view,
218 View* relative_view, 218 View* relative_view,
219 OrderDirection direction) OVERRIDE { 219 OrderDirection direction) override {
220 DCHECK_EQ(view, view_); 220 DCHECK_EQ(view, view_);
221 QuitRunLoop(); 221 QuitRunLoop();
222 } 222 }
223 223
224 View* view_; 224 View* view_;
225 225
226 DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver); 226 DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
227 }; 227 };
228 228
229 void WaitForOrderChange(ViewManager* view_manager, View* view) { 229 void WaitForOrderChange(ViewManager* view_manager, View* view) {
230 OrderChangeObserver observer(view); 230 OrderChangeObserver observer(view);
231 DoRunLoop(); 231 DoRunLoop();
232 } 232 }
233 233
234 // Tracks a view's destruction. Query is_valid() for current state. 234 // Tracks a view's destruction. Query is_valid() for current state.
235 class ViewTracker : public ViewObserver { 235 class ViewTracker : public ViewObserver {
236 public: 236 public:
237 explicit ViewTracker(View* view) : view_(view) { 237 explicit ViewTracker(View* view) : view_(view) {
238 view_->AddObserver(this); 238 view_->AddObserver(this);
239 } 239 }
240 virtual ~ViewTracker() { 240 virtual ~ViewTracker() {
241 if (view_) 241 if (view_)
242 view_->RemoveObserver(this); 242 view_->RemoveObserver(this);
243 } 243 }
244 244
245 bool is_valid() const { return !!view_; } 245 bool is_valid() const { return !!view_; }
246 246
247 private: 247 private:
248 // Overridden from ViewObserver: 248 // Overridden from ViewObserver:
249 virtual void OnViewDestroyed(View* view) OVERRIDE { 249 virtual void OnViewDestroyed(View* view) override {
250 DCHECK_EQ(view, view_); 250 DCHECK_EQ(view, view_);
251 view_ = NULL; 251 view_ = NULL;
252 } 252 }
253 253
254 int id_; 254 int id_;
255 View* view_; 255 View* view_;
256 256
257 DISALLOW_COPY_AND_ASSIGN(ViewTracker); 257 DISALLOW_COPY_AND_ASSIGN(ViewTracker);
258 }; 258 };
259 259
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 loaded_view_manager_ = NULL; 295 loaded_view_manager_ = NULL;
296 return view_manager; 296 return view_manager;
297 } 297 }
298 298
299 void UnloadApplication(const GURL& url) { 299 void UnloadApplication(const GURL& url) {
300 test_helper_.SetLoaderForURL(scoped_ptr<ApplicationLoader>(), url); 300 test_helper_.SetLoaderForURL(scoped_ptr<ApplicationLoader>(), url);
301 } 301 }
302 302
303 private: 303 private:
304 // Overridden from testing::Test: 304 // Overridden from testing::Test:
305 virtual void SetUp() OVERRIDE { 305 virtual void SetUp() override {
306 ConnectApplicationLoader::LoadedCallback ready_callback = base::Bind( 306 ConnectApplicationLoader::LoadedCallback ready_callback = base::Bind(
307 &ViewManagerTest::OnViewManagerLoaded, base::Unretained(this)); 307 &ViewManagerTest::OnViewManagerLoaded, base::Unretained(this));
308 test_helper_.Init(); 308 test_helper_.Init();
309 test_helper_.SetLoaderForURL( 309 test_helper_.SetLoaderForURL(
310 scoped_ptr<ApplicationLoader>( 310 scoped_ptr<ApplicationLoader>(
311 new ConnectApplicationLoader(ready_callback)), 311 new ConnectApplicationLoader(ready_callback)),
312 GURL(kWindowManagerURL)); 312 GURL(kWindowManagerURL));
313 test_helper_.SetLoaderForURL( 313 test_helper_.SetLoaderForURL(
314 scoped_ptr<ApplicationLoader>( 314 scoped_ptr<ApplicationLoader>(
315 new ConnectApplicationLoader(ready_callback)), 315 new ConnectApplicationLoader(ready_callback)),
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 class VisibilityChangeObserver : public ViewObserver { 533 class VisibilityChangeObserver : public ViewObserver {
534 public: 534 public:
535 explicit VisibilityChangeObserver(View* view) : view_(view) { 535 explicit VisibilityChangeObserver(View* view) : view_(view) {
536 view_->AddObserver(this); 536 view_->AddObserver(this);
537 } 537 }
538 virtual ~VisibilityChangeObserver() { view_->RemoveObserver(this); } 538 virtual ~VisibilityChangeObserver() { view_->RemoveObserver(this); }
539 539
540 private: 540 private:
541 // Overridden from ViewObserver: 541 // Overridden from ViewObserver:
542 virtual void OnViewVisibilityChanged(View* view) OVERRIDE { 542 virtual void OnViewVisibilityChanged(View* view) override {
543 EXPECT_EQ(view, view_); 543 EXPECT_EQ(view, view_);
544 QuitRunLoop(); 544 QuitRunLoop();
545 } 545 }
546 546
547 View* view_; 547 View* view_;
548 548
549 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); 549 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
550 }; 550 };
551 551
552 } // namespace 552 } // namespace
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 class DrawnChangeObserver : public ViewObserver { 595 class DrawnChangeObserver : public ViewObserver {
596 public: 596 public:
597 explicit DrawnChangeObserver(View* view) : view_(view) { 597 explicit DrawnChangeObserver(View* view) : view_(view) {
598 view_->AddObserver(this); 598 view_->AddObserver(this);
599 } 599 }
600 virtual ~DrawnChangeObserver() { view_->RemoveObserver(this); } 600 virtual ~DrawnChangeObserver() { view_->RemoveObserver(this); }
601 601
602 private: 602 private:
603 // Overridden from ViewObserver: 603 // Overridden from ViewObserver:
604 virtual void OnViewDrawnChanged(View* view) OVERRIDE { 604 virtual void OnViewDrawnChanged(View* view) override {
605 EXPECT_EQ(view, view_); 605 EXPECT_EQ(view, view_);
606 QuitRunLoop(); 606 QuitRunLoop();
607 } 607 }
608 608
609 View* view_; 609 View* view_;
610 610
611 DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver); 611 DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver);
612 }; 612 };
613 613
614 } // namespace 614 } // namespace
(...skipping 26 matching lines...) Expand all
641 641
642 // TODO(beng): tests for view event dispatcher. 642 // TODO(beng): tests for view event dispatcher.
643 // - verify that we see events for all views. 643 // - verify that we see events for all views.
644 644
645 // TODO(beng): tests for focus: 645 // TODO(beng): tests for focus:
646 // - focus between two views known to a connection 646 // - focus between two views known to a connection
647 // - focus between views unknown to one of the connections. 647 // - focus between views unknown to one of the connections.
648 // - focus between views unknown to either connection. 648 // - focus between views unknown to either connection.
649 649
650 } // namespace mojo 650 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698