| OLD | NEW |
| 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.h" | 5 #include "mojo/services/public/cpp/view_manager/view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
| 10 #include "mojo/services/public/cpp/view_manager/util.h" | 10 #include "mojo/services/public/cpp/view_manager/util.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void Reset() { | 124 void Reset() { |
| 125 received_params_.clear(); | 125 received_params_.clear(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 const std::vector<TreeChangeParams>& received_params() { | 128 const std::vector<TreeChangeParams>& received_params() { |
| 129 return received_params_; | 129 return received_params_; |
| 130 } | 130 } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 // Overridden from ViewObserver: | 133 // Overridden from ViewObserver: |
| 134 virtual void OnTreeChanging(const TreeChangeParams& params) OVERRIDE { | 134 virtual void OnTreeChanging(const TreeChangeParams& params) override { |
| 135 received_params_.push_back(params); | 135 received_params_.push_back(params); |
| 136 } | 136 } |
| 137 virtual void OnTreeChanged(const TreeChangeParams& params) OVERRIDE { | 137 virtual void OnTreeChanged(const TreeChangeParams& params) override { |
| 138 received_params_.push_back(params); | 138 received_params_.push_back(params); |
| 139 } | 139 } |
| 140 | 140 |
| 141 View* observee_; | 141 View* observee_; |
| 142 std::vector<TreeChangeParams> received_params_; | 142 std::vector<TreeChangeParams> received_params_; |
| 143 | 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver); | 144 DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // Adds/Removes v11 to v1. | 147 // Adds/Removes v11 to v1. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 Changes GetAndClearChanges() { | 360 Changes GetAndClearChanges() { |
| 361 Changes changes; | 361 Changes changes; |
| 362 changes_.swap(changes); | 362 changes_.swap(changes); |
| 363 return changes; | 363 return changes; |
| 364 } | 364 } |
| 365 | 365 |
| 366 private: | 366 private: |
| 367 // Overridden from ViewObserver: | 367 // Overridden from ViewObserver: |
| 368 virtual void OnViewReordering(View* view, | 368 virtual void OnViewReordering(View* view, |
| 369 View* relative_view, | 369 View* relative_view, |
| 370 OrderDirection direction) OVERRIDE { | 370 OrderDirection direction) override { |
| 371 OnViewReordered(view, relative_view, direction); | 371 OnViewReordered(view, relative_view, direction); |
| 372 } | 372 } |
| 373 | 373 |
| 374 virtual void OnViewReordered(View* view, | 374 virtual void OnViewReordered(View* view, |
| 375 View* relative_view, | 375 View* relative_view, |
| 376 OrderDirection direction) OVERRIDE { | 376 OrderDirection direction) override { |
| 377 Change change; | 377 Change change; |
| 378 change.view = view; | 378 change.view = view; |
| 379 change.relative_view = relative_view; | 379 change.relative_view = relative_view; |
| 380 change.direction = direction; | 380 change.direction = direction; |
| 381 changes_.push_back(change); | 381 changes_.push_back(change); |
| 382 } | 382 } |
| 383 | 383 |
| 384 View* observee_; | 384 View* observee_; |
| 385 Changes changes_; | 385 Changes changes_; |
| 386 | 386 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 Changes GetAndClearChanges() { | 507 Changes GetAndClearChanges() { |
| 508 Changes changes; | 508 Changes changes; |
| 509 changes.swap(changes_); | 509 changes.swap(changes_); |
| 510 return changes; | 510 return changes; |
| 511 } | 511 } |
| 512 | 512 |
| 513 private: | 513 private: |
| 514 // Overridden from ViewObserver: | 514 // Overridden from ViewObserver: |
| 515 virtual void OnViewBoundsChanging(View* view, | 515 virtual void OnViewBoundsChanging(View* view, |
| 516 const gfx::Rect& old_bounds, | 516 const gfx::Rect& old_bounds, |
| 517 const gfx::Rect& new_bounds) OVERRIDE { | 517 const gfx::Rect& new_bounds) override { |
| 518 changes_.push_back( | 518 changes_.push_back( |
| 519 base::StringPrintf( | 519 base::StringPrintf( |
| 520 "view=%s old_bounds=%s new_bounds=%s phase=changing", | 520 "view=%s old_bounds=%s new_bounds=%s phase=changing", |
| 521 ViewIdToString(view->id()).c_str(), | 521 ViewIdToString(view->id()).c_str(), |
| 522 RectToString(old_bounds).c_str(), | 522 RectToString(old_bounds).c_str(), |
| 523 RectToString(new_bounds).c_str())); | 523 RectToString(new_bounds).c_str())); |
| 524 } | 524 } |
| 525 virtual void OnViewBoundsChanged(View* view, | 525 virtual void OnViewBoundsChanged(View* view, |
| 526 const gfx::Rect& old_bounds, | 526 const gfx::Rect& old_bounds, |
| 527 const gfx::Rect& new_bounds) OVERRIDE { | 527 const gfx::Rect& new_bounds) override { |
| 528 changes_.push_back( | 528 changes_.push_back( |
| 529 base::StringPrintf( | 529 base::StringPrintf( |
| 530 "view=%s old_bounds=%s new_bounds=%s phase=changed", | 530 "view=%s old_bounds=%s new_bounds=%s phase=changed", |
| 531 ViewIdToString(view->id()).c_str(), | 531 ViewIdToString(view->id()).c_str(), |
| 532 RectToString(old_bounds).c_str(), | 532 RectToString(old_bounds).c_str(), |
| 533 RectToString(new_bounds).c_str())); | 533 RectToString(new_bounds).c_str())); |
| 534 } | 534 } |
| 535 | 535 |
| 536 View* view_; | 536 View* view_; |
| 537 Changes changes_; | 537 Changes changes_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 568 virtual ~VisibilityChangeObserver() { view_->RemoveObserver(this); } | 568 virtual ~VisibilityChangeObserver() { view_->RemoveObserver(this); } |
| 569 | 569 |
| 570 Changes GetAndClearChanges() { | 570 Changes GetAndClearChanges() { |
| 571 Changes changes; | 571 Changes changes; |
| 572 changes.swap(changes_); | 572 changes.swap(changes_); |
| 573 return changes; | 573 return changes; |
| 574 } | 574 } |
| 575 | 575 |
| 576 private: | 576 private: |
| 577 // Overridden from ViewObserver: | 577 // Overridden from ViewObserver: |
| 578 virtual void OnViewVisibilityChanging(View* view) OVERRIDE { | 578 virtual void OnViewVisibilityChanging(View* view) override { |
| 579 changes_.push_back( | 579 changes_.push_back( |
| 580 base::StringPrintf("view=%s phase=changing visibility=%s", | 580 base::StringPrintf("view=%s phase=changing visibility=%s", |
| 581 ViewIdToString(view->id()).c_str(), | 581 ViewIdToString(view->id()).c_str(), |
| 582 view->visible() ? "true" : "false")); | 582 view->visible() ? "true" : "false")); |
| 583 } | 583 } |
| 584 virtual void OnViewVisibilityChanged(View* view) OVERRIDE { | 584 virtual void OnViewVisibilityChanged(View* view) override { |
| 585 changes_.push_back(base::StringPrintf("view=%s phase=changed visibility=%s", | 585 changes_.push_back(base::StringPrintf("view=%s phase=changed visibility=%s", |
| 586 ViewIdToString(view->id()).c_str(), | 586 ViewIdToString(view->id()).c_str(), |
| 587 view->visible() ? "true" : "false")); | 587 view->visible() ? "true" : "false")); |
| 588 } | 588 } |
| 589 | 589 |
| 590 View* view_; | 590 View* view_; |
| 591 Changes changes_; | 591 Changes changes_; |
| 592 | 592 |
| 593 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); | 593 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); |
| 594 }; | 594 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 610 } | 610 } |
| 611 { | 611 { |
| 612 // Set visible to existing value and verify no notifications. | 612 // Set visible to existing value and verify no notifications. |
| 613 VisibilityChangeObserver observer(&v1); | 613 VisibilityChangeObserver observer(&v1); |
| 614 v1.SetVisible(false); | 614 v1.SetVisible(false); |
| 615 EXPECT_TRUE(observer.GetAndClearChanges().empty()); | 615 EXPECT_TRUE(observer.GetAndClearChanges().empty()); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 } // namespace mojo | 619 } // namespace mojo |
| OLD | NEW |