OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/v2/public/view.h" | 5 #include "ui/v2/public/view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
10 #include "ui/compositor/layer_type.h" | 10 #include "ui/compositor/layer_type.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 void Reset() { | 131 void Reset() { |
132 received_params_.clear(); | 132 received_params_.clear(); |
133 } | 133 } |
134 | 134 |
135 const std::vector<TreeChangeParams>& received_params() { | 135 const std::vector<TreeChangeParams>& received_params() { |
136 return received_params_; | 136 return received_params_; |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 // Overridden from ViewObserver: | 140 // Overridden from ViewObserver: |
141 virtual void OnViewTreeChange(const TreeChangeParams& params) OVERRIDE { | 141 virtual void OnViewTreeChange(const TreeChangeParams& params) override { |
142 received_params_.push_back(params); | 142 received_params_.push_back(params); |
143 } | 143 } |
144 | 144 |
145 View* observee_; | 145 View* observee_; |
146 std::vector<TreeChangeParams> received_params_; | 146 std::vector<TreeChangeParams> received_params_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver); | 148 DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver); |
149 }; | 149 }; |
150 | 150 |
151 // Adds/Removes v11 to v1. | 151 // Adds/Removes v11 to v1. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 virtual ~VisibilityObserver() { | 387 virtual ~VisibilityObserver() { |
388 view_->RemoveObserver(this); | 388 view_->RemoveObserver(this); |
389 } | 389 } |
390 | 390 |
391 const LogEntries& log_entries() const { return log_entries_; } | 391 const LogEntries& log_entries() const { return log_entries_; } |
392 | 392 |
393 private: | 393 private: |
394 // Overridden from ViewObserver: | 394 // Overridden from ViewObserver: |
395 virtual void OnViewVisibilityChange( | 395 virtual void OnViewVisibilityChange( |
396 View* view, | 396 View* view, |
397 ViewObserver::DispositionChangePhase phase) OVERRIDE { | 397 ViewObserver::DispositionChangePhase phase) override { |
398 DCHECK_EQ(view_, view); | 398 DCHECK_EQ(view_, view); |
399 log_entries_.push_back(std::make_pair(phase, view->visible())); | 399 log_entries_.push_back(std::make_pair(phase, view->visible())); |
400 } | 400 } |
401 | 401 |
402 View* view_; | 402 View* view_; |
403 LogEntries log_entries_; | 403 LogEntries log_entries_; |
404 | 404 |
405 DISALLOW_COPY_AND_ASSIGN(VisibilityObserver); | 405 DISALLOW_COPY_AND_ASSIGN(VisibilityObserver); |
406 }; | 406 }; |
407 | 407 |
(...skipping 21 matching lines...) Expand all Loading... |
429 } | 429 } |
430 virtual ~BoundsObserver() { | 430 virtual ~BoundsObserver() { |
431 view_->RemoveObserver(this); | 431 view_->RemoveObserver(this); |
432 } | 432 } |
433 | 433 |
434 const BoundsChanges& bounds_changes() const { return bounds_changes_; } | 434 const BoundsChanges& bounds_changes() const { return bounds_changes_; } |
435 | 435 |
436 private: | 436 private: |
437 virtual void OnViewBoundsChanged(View* view, | 437 virtual void OnViewBoundsChanged(View* view, |
438 const gfx::Rect& old_bounds, | 438 const gfx::Rect& old_bounds, |
439 const gfx::Rect& new_bounds) OVERRIDE { | 439 const gfx::Rect& new_bounds) override { |
440 DCHECK_EQ(view_, view); | 440 DCHECK_EQ(view_, view); |
441 bounds_changes_.push_back(std::make_pair(old_bounds, new_bounds)); | 441 bounds_changes_.push_back(std::make_pair(old_bounds, new_bounds)); |
442 } | 442 } |
443 | 443 |
444 View* view_; | 444 View* view_; |
445 BoundsChanges bounds_changes_; | 445 BoundsChanges bounds_changes_; |
446 | 446 |
447 DISALLOW_COPY_AND_ASSIGN(BoundsObserver); | 447 DISALLOW_COPY_AND_ASSIGN(BoundsObserver); |
448 }; | 448 }; |
449 | 449 |
450 TEST_F(ViewObserverTest, BoundsChanged) { | 450 TEST_F(ViewObserverTest, BoundsChanged) { |
451 View v1; | 451 View v1; |
452 BoundsObserver o1(&v1); | 452 BoundsObserver o1(&v1); |
453 | 453 |
454 gfx::Rect new_bounds(0, 0, 10, 10); | 454 gfx::Rect new_bounds(0, 0, 10, 10); |
455 | 455 |
456 v1.SetBounds(new_bounds); | 456 v1.SetBounds(new_bounds); |
457 EXPECT_EQ(1U, o1.bounds_changes().size()); | 457 EXPECT_EQ(1U, o1.bounds_changes().size()); |
458 EXPECT_EQ(gfx::Rect(), o1.bounds_changes().front().first); | 458 EXPECT_EQ(gfx::Rect(), o1.bounds_changes().front().first); |
459 EXPECT_EQ(new_bounds, o1.bounds_changes().front().second); | 459 EXPECT_EQ(new_bounds, o1.bounds_changes().front().second); |
460 } | 460 } |
461 | 461 |
462 } // namespace v2 | 462 } // namespace v2 |
OLD | NEW |