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

Side by Side Diff: mojo/services/view_manager/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: 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 main_run_loop_->Quit(); 269 main_run_loop_->Quit();
270 } 270 }
271 271
272 void GotViewTree(std::vector<TestView>* views, Array<ViewDataPtr> results) { 272 void GotViewTree(std::vector<TestView>* views, Array<ViewDataPtr> results) {
273 ViewDatasToTestViews(results, views); 273 ViewDatasToTestViews(results, views);
274 DCHECK(main_run_loop_); 274 DCHECK(main_run_loop_);
275 main_run_loop_->Quit(); 275 main_run_loop_->Quit();
276 } 276 }
277 277
278 // TestChangeTracker::Delegate: 278 // TestChangeTracker::Delegate:
279 virtual void OnChangeAdded() OVERRIDE { 279 virtual void OnChangeAdded() override {
280 if (quit_count_ > 0 && --quit_count_ == 0) 280 if (quit_count_ > 0 && --quit_count_ == 0)
281 QuitCountReached(); 281 QuitCountReached();
282 } 282 }
283 283
284 static ViewManagerProxy* instance_; 284 static ViewManagerProxy* instance_;
285 static base::RunLoop* main_run_loop_; 285 static base::RunLoop* main_run_loop_;
286 static bool in_embed_; 286 static bool in_embed_;
287 287
288 TestChangeTracker* tracker_; 288 TestChangeTracker* tracker_;
289 289
(...skipping 22 matching lines...) Expand all
312 bool ViewManagerProxy::in_embed_ = false; 312 bool ViewManagerProxy::in_embed_ = false;
313 313
314 class TestViewManagerClientConnection 314 class TestViewManagerClientConnection
315 : public InterfaceImpl<ViewManagerClient> { 315 : public InterfaceImpl<ViewManagerClient> {
316 public: 316 public:
317 TestViewManagerClientConnection() : connection_(&tracker_) { 317 TestViewManagerClientConnection() : connection_(&tracker_) {
318 tracker_.set_delegate(&connection_); 318 tracker_.set_delegate(&connection_);
319 } 319 }
320 320
321 // InterfaceImpl: 321 // InterfaceImpl:
322 virtual void OnConnectionEstablished() OVERRIDE { 322 virtual void OnConnectionEstablished() override {
323 connection_.set_router(internal_state()->router()); 323 connection_.set_router(internal_state()->router());
324 connection_.set_view_manager(client()); 324 connection_.set_view_manager(client());
325 } 325 }
326 326
327 // ViewManagerClient: 327 // ViewManagerClient:
328 virtual void OnEmbed( 328 virtual void OnEmbed(
329 ConnectionSpecificId connection_id, 329 ConnectionSpecificId connection_id,
330 const String& creator_url, 330 const String& creator_url,
331 ViewDataPtr root, 331 ViewDataPtr root,
332 InterfaceRequest<ServiceProvider> services) OVERRIDE { 332 InterfaceRequest<ServiceProvider> services) override {
333 tracker_.OnEmbed(connection_id, creator_url, root.Pass()); 333 tracker_.OnEmbed(connection_id, creator_url, root.Pass());
334 } 334 }
335 virtual void OnViewBoundsChanged(Id view_id, 335 virtual void OnViewBoundsChanged(Id view_id,
336 RectPtr old_bounds, 336 RectPtr old_bounds,
337 RectPtr new_bounds) OVERRIDE { 337 RectPtr new_bounds) override {
338 tracker_.OnViewBoundsChanged(view_id, old_bounds.Pass(), new_bounds.Pass()); 338 tracker_.OnViewBoundsChanged(view_id, old_bounds.Pass(), new_bounds.Pass());
339 } 339 }
340 virtual void OnViewHierarchyChanged(Id view, 340 virtual void OnViewHierarchyChanged(Id view,
341 Id new_parent, 341 Id new_parent,
342 Id old_parent, 342 Id old_parent,
343 Array<ViewDataPtr> views) OVERRIDE { 343 Array<ViewDataPtr> views) override {
344 tracker_.OnViewHierarchyChanged(view, new_parent, old_parent, views.Pass()); 344 tracker_.OnViewHierarchyChanged(view, new_parent, old_parent, views.Pass());
345 } 345 }
346 virtual void OnViewReordered(Id view_id, 346 virtual void OnViewReordered(Id view_id,
347 Id relative_view_id, 347 Id relative_view_id,
348 OrderDirection direction) OVERRIDE { 348 OrderDirection direction) override {
349 tracker_.OnViewReordered(view_id, relative_view_id, direction); 349 tracker_.OnViewReordered(view_id, relative_view_id, direction);
350 } 350 }
351 virtual void OnViewDeleted(Id view) OVERRIDE { tracker_.OnViewDeleted(view); } 351 virtual void OnViewDeleted(Id view) override { tracker_.OnViewDeleted(view); }
352 virtual void OnViewVisibilityChanged(uint32_t view, bool visible) OVERRIDE { 352 virtual void OnViewVisibilityChanged(uint32_t view, bool visible) override {
353 tracker_.OnViewVisibilityChanged(view, visible); 353 tracker_.OnViewVisibilityChanged(view, visible);
354 } 354 }
355 virtual void OnViewDrawnStateChanged(uint32_t view, bool drawn) OVERRIDE { 355 virtual void OnViewDrawnStateChanged(uint32_t view, bool drawn) override {
356 tracker_.OnViewDrawnStateChanged(view, drawn); 356 tracker_.OnViewDrawnStateChanged(view, drawn);
357 } 357 }
358 virtual void OnViewInputEvent(Id view_id, 358 virtual void OnViewInputEvent(Id view_id,
359 EventPtr event, 359 EventPtr event,
360 const Callback<void()>& callback) OVERRIDE { 360 const Callback<void()>& callback) override {
361 tracker_.OnViewInputEvent(view_id, event.Pass()); 361 tracker_.OnViewInputEvent(view_id, event.Pass());
362 } 362 }
363 virtual void Embed( 363 virtual void Embed(
364 const String& url, 364 const String& url,
365 InterfaceRequest<ServiceProvider> service_provider) OVERRIDE { 365 InterfaceRequest<ServiceProvider> service_provider) override {
366 tracker_.DelegateEmbed(url); 366 tracker_.DelegateEmbed(url);
367 } 367 }
368 virtual void DispatchOnViewInputEvent(mojo::EventPtr event) OVERRIDE { 368 virtual void DispatchOnViewInputEvent(mojo::EventPtr event) override {
369 } 369 }
370 370
371 private: 371 private:
372 TestChangeTracker tracker_; 372 TestChangeTracker tracker_;
373 ViewManagerProxy connection_; 373 ViewManagerProxy connection_;
374 374
375 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); 375 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection);
376 }; 376 };
377 377
378 // Used with ViewManagerService::Embed(). Creates a 378 // Used with ViewManagerService::Embed(). Creates a
379 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. 379 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy.
380 class EmbedApplicationLoader : public ApplicationLoader, 380 class EmbedApplicationLoader : public ApplicationLoader,
381 ApplicationDelegate, 381 ApplicationDelegate,
382 public InterfaceFactory<ViewManagerClient> { 382 public InterfaceFactory<ViewManagerClient> {
383 public: 383 public:
384 EmbedApplicationLoader() {} 384 EmbedApplicationLoader() {}
385 virtual ~EmbedApplicationLoader() {} 385 virtual ~EmbedApplicationLoader() {}
386 386
387 // ApplicationLoader implementation: 387 // ApplicationLoader implementation:
388 virtual void Load(ApplicationManager* manager, 388 virtual void Load(ApplicationManager* manager,
389 const GURL& url, 389 const GURL& url,
390 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE { 390 scoped_refptr<LoadCallbacks> callbacks) override {
391 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication(); 391 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication();
392 if (!shell_handle.is_valid()) 392 if (!shell_handle.is_valid())
393 return; 393 return;
394 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, 394 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this,
395 shell_handle.Pass())); 395 shell_handle.Pass()));
396 apps_.push_back(app.release()); 396 apps_.push_back(app.release());
397 } 397 }
398 virtual void OnApplicationError(ApplicationManager* manager, 398 virtual void OnApplicationError(ApplicationManager* manager,
399 const GURL& url) OVERRIDE {} 399 const GURL& url) override {}
400 400
401 // ApplicationDelegate implementation: 401 // ApplicationDelegate implementation:
402 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 402 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
403 OVERRIDE { 403 override {
404 connection->AddService(this); 404 connection->AddService(this);
405 return true; 405 return true;
406 } 406 }
407 407
408 // InterfaceFactory<ViewManagerClient> implementation: 408 // InterfaceFactory<ViewManagerClient> implementation:
409 virtual void Create(ApplicationConnection* connection, 409 virtual void Create(ApplicationConnection* connection,
410 InterfaceRequest<ViewManagerClient> request) OVERRIDE { 410 InterfaceRequest<ViewManagerClient> request) override {
411 BindToRequest(new TestViewManagerClientConnection, &request); 411 BindToRequest(new TestViewManagerClientConnection, &request);
412 } 412 }
413 413
414 private: 414 private:
415 ScopedVector<ApplicationImpl> apps_; 415 ScopedVector<ApplicationImpl> apps_;
416 416
417 DISALLOW_COPY_AND_ASSIGN(EmbedApplicationLoader); 417 DISALLOW_COPY_AND_ASSIGN(EmbedApplicationLoader);
418 }; 418 };
419 419
420 // Creates an id used for transport from the specified parameters. 420 // Creates an id used for transport from the specified parameters.
(...skipping 29 matching lines...) Expand all
450 450
451 typedef std::vector<std::string> Changes; 451 typedef std::vector<std::string> Changes;
452 452
453 class ViewManagerTest : public testing::Test { 453 class ViewManagerTest : public testing::Test {
454 public: 454 public:
455 ViewManagerTest() 455 ViewManagerTest()
456 : connection_(NULL), 456 : connection_(NULL),
457 connection2_(NULL), 457 connection2_(NULL),
458 connection3_(NULL) {} 458 connection3_(NULL) {}
459 459
460 virtual void SetUp() OVERRIDE { 460 virtual void SetUp() override {
461 ASSERT_TRUE(ViewManagerProxy::IsInInitialState()); 461 ASSERT_TRUE(ViewManagerProxy::IsInInitialState());
462 test_helper_.Init(); 462 test_helper_.Init();
463 463
464 #if defined(OS_WIN) 464 #if defined(OS_WIN)
465 // As we unload the wndproc of window classes we need to be sure to 465 // As we unload the wndproc of window classes we need to be sure to
466 // unregister them. 466 // unregister them.
467 gfx::WindowImpl::UnregisterClassesAtExit(); 467 gfx::WindowImpl::UnregisterClassesAtExit();
468 #endif 468 #endif
469 469
470 test_helper_.SetLoaderForURL( 470 test_helper_.SetLoaderForURL(
471 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), 471 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()),
472 GURL(kTestServiceURL)); 472 GURL(kTestServiceURL));
473 473
474 test_helper_.SetLoaderForURL( 474 test_helper_.SetLoaderForURL(
475 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()), 475 scoped_ptr<ApplicationLoader>(new EmbedApplicationLoader()),
476 GURL(kTestServiceURL2)); 476 GURL(kTestServiceURL2));
477 477
478 test_helper_.application_manager()->ConnectToService( 478 test_helper_.application_manager()->ConnectToService(
479 GURL("mojo:mojo_view_manager"), &view_manager_init_); 479 GURL("mojo:mojo_view_manager"), &view_manager_init_);
480 ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 1)); 480 ASSERT_TRUE(InitEmbed(view_manager_init_.get(), kTestServiceURL, 1));
481 481
482 connection_ = ViewManagerProxy::WaitForInstance(); 482 connection_ = ViewManagerProxy::WaitForInstance();
483 ASSERT_TRUE(connection_ != NULL); 483 ASSERT_TRUE(connection_ != NULL);
484 connection_->DoRunLoopUntilChangesCount(1); 484 connection_->DoRunLoopUntilChangesCount(1);
485 } 485 }
486 486
487 virtual void TearDown() OVERRIDE { 487 virtual void TearDown() override {
488 if (connection3_) 488 if (connection3_)
489 connection3_->Destroy(); 489 connection3_->Destroy();
490 if (connection2_) 490 if (connection2_)
491 connection2_->Destroy(); 491 connection2_->Destroy();
492 if (connection_) 492 if (connection_)
493 connection_->Destroy(); 493 connection_->Destroy();
494 } 494 }
495 495
496 protected: 496 protected:
497 void EstablishSecondConnectionWithRoot(Id root_id) { 497 void EstablishSecondConnectionWithRoot(Id root_id) {
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 1425
1426 // TODO(sky): add coverage of test that destroys connections and ensures other 1426 // TODO(sky): add coverage of test that destroys connections and ensures other
1427 // connections get deletion notification. 1427 // connections get deletion notification.
1428 1428
1429 // TODO(sky): need to better track changes to initial connection. For example, 1429 // TODO(sky): need to better track changes to initial connection. For example,
1430 // that SetBounsdViews/AddView and the like don't result in messages to the 1430 // that SetBounsdViews/AddView and the like don't result in messages to the
1431 // originating connection. 1431 // originating connection.
1432 1432
1433 } // namespace service 1433 } // namespace service
1434 } // namespace mojo 1434 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698