| OLD | NEW |
| 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DECLARE_WINDOW_PROPERTY_TYPE(int) | 48 DECLARE_WINDOW_PROPERTY_TYPE(int) |
| 49 | 49 |
| 50 namespace aura { | 50 namespace aura { |
| 51 namespace test { | 51 namespace test { |
| 52 | 52 |
| 53 class WindowTest : public AuraTestBase { | 53 class WindowTest : public AuraTestBase { |
| 54 public: | 54 public: |
| 55 WindowTest() : max_separation_(0) { | 55 WindowTest() : max_separation_(0) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void SetUp() OVERRIDE { | 58 virtual void SetUp() override { |
| 59 AuraTestBase::SetUp(); | 59 AuraTestBase::SetUp(); |
| 60 // TODO: there needs to be an easier way to do this. | 60 // TODO: there needs to be an easier way to do this. |
| 61 max_separation_ = ui::GestureConfiguration:: | 61 max_separation_ = ui::GestureConfiguration:: |
| 62 max_separation_for_gesture_touches_in_pixels(); | 62 max_separation_for_gesture_touches_in_pixels(); |
| 63 ui::GestureConfiguration:: | 63 ui::GestureConfiguration:: |
| 64 set_max_separation_for_gesture_touches_in_pixels(0); | 64 set_max_separation_for_gesture_touches_in_pixels(0); |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void TearDown() OVERRIDE { | 67 virtual void TearDown() override { |
| 68 AuraTestBase::TearDown(); | 68 AuraTestBase::TearDown(); |
| 69 ui::GestureConfiguration:: | 69 ui::GestureConfiguration:: |
| 70 set_max_separation_for_gesture_touches_in_pixels(max_separation_); | 70 set_max_separation_for_gesture_touches_in_pixels(max_separation_); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 int max_separation_; | 74 int max_separation_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(WindowTest); | 76 DISALLOW_COPY_AND_ASSIGN(WindowTest); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 namespace { | 79 namespace { |
| 80 | 80 |
| 81 // Used for verifying destruction methods are invoked. | 81 // Used for verifying destruction methods are invoked. |
| 82 class DestroyTrackingDelegateImpl : public TestWindowDelegate { | 82 class DestroyTrackingDelegateImpl : public TestWindowDelegate { |
| 83 public: | 83 public: |
| 84 DestroyTrackingDelegateImpl() | 84 DestroyTrackingDelegateImpl() |
| 85 : destroying_count_(0), | 85 : destroying_count_(0), |
| 86 destroyed_count_(0), | 86 destroyed_count_(0), |
| 87 in_destroying_(false) {} | 87 in_destroying_(false) {} |
| 88 | 88 |
| 89 void clear_destroying_count() { destroying_count_ = 0; } | 89 void clear_destroying_count() { destroying_count_ = 0; } |
| 90 int destroying_count() const { return destroying_count_; } | 90 int destroying_count() const { return destroying_count_; } |
| 91 | 91 |
| 92 void clear_destroyed_count() { destroyed_count_ = 0; } | 92 void clear_destroyed_count() { destroyed_count_ = 0; } |
| 93 int destroyed_count() const { return destroyed_count_; } | 93 int destroyed_count() const { return destroyed_count_; } |
| 94 | 94 |
| 95 bool in_destroying() const { return in_destroying_; } | 95 bool in_destroying() const { return in_destroying_; } |
| 96 | 96 |
| 97 virtual void OnWindowDestroying(Window* window) OVERRIDE { | 97 virtual void OnWindowDestroying(Window* window) override { |
| 98 EXPECT_FALSE(in_destroying_); | 98 EXPECT_FALSE(in_destroying_); |
| 99 in_destroying_ = true; | 99 in_destroying_ = true; |
| 100 destroying_count_++; | 100 destroying_count_++; |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 103 virtual void OnWindowDestroyed(Window* window) override { |
| 104 EXPECT_TRUE(in_destroying_); | 104 EXPECT_TRUE(in_destroying_); |
| 105 in_destroying_ = false; | 105 in_destroying_ = false; |
| 106 destroyed_count_++; | 106 destroyed_count_++; |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 int destroying_count_; | 110 int destroying_count_; |
| 111 int destroyed_count_; | 111 int destroyed_count_; |
| 112 bool in_destroying_; | 112 bool in_destroying_; |
| 113 | 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(DestroyTrackingDelegateImpl); | 114 DISALLOW_COPY_AND_ASSIGN(DestroyTrackingDelegateImpl); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // Used to verify that when OnWindowDestroying is invoked the parent is also | 117 // Used to verify that when OnWindowDestroying is invoked the parent is also |
| 118 // is in the process of being destroyed. | 118 // is in the process of being destroyed. |
| 119 class ChildWindowDelegateImpl : public DestroyTrackingDelegateImpl { | 119 class ChildWindowDelegateImpl : public DestroyTrackingDelegateImpl { |
| 120 public: | 120 public: |
| 121 explicit ChildWindowDelegateImpl( | 121 explicit ChildWindowDelegateImpl( |
| 122 DestroyTrackingDelegateImpl* parent_delegate) | 122 DestroyTrackingDelegateImpl* parent_delegate) |
| 123 : parent_delegate_(parent_delegate) { | 123 : parent_delegate_(parent_delegate) { |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual void OnWindowDestroying(Window* window) OVERRIDE { | 126 virtual void OnWindowDestroying(Window* window) override { |
| 127 EXPECT_TRUE(parent_delegate_->in_destroying()); | 127 EXPECT_TRUE(parent_delegate_->in_destroying()); |
| 128 DestroyTrackingDelegateImpl::OnWindowDestroying(window); | 128 DestroyTrackingDelegateImpl::OnWindowDestroying(window); |
| 129 } | 129 } |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 DestroyTrackingDelegateImpl* parent_delegate_; | 132 DestroyTrackingDelegateImpl* parent_delegate_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(ChildWindowDelegateImpl); | 134 DISALLOW_COPY_AND_ASSIGN(ChildWindowDelegateImpl); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // Used to verify that a Window is removed from its parent when | 137 // Used to verify that a Window is removed from its parent when |
| 138 // OnWindowDestroyed is called. | 138 // OnWindowDestroyed is called. |
| 139 class DestroyOrphanDelegate : public TestWindowDelegate { | 139 class DestroyOrphanDelegate : public TestWindowDelegate { |
| 140 public: | 140 public: |
| 141 DestroyOrphanDelegate() : window_(NULL) { | 141 DestroyOrphanDelegate() : window_(NULL) { |
| 142 } | 142 } |
| 143 | 143 |
| 144 void set_window(Window* window) { window_ = window; } | 144 void set_window(Window* window) { window_ = window; } |
| 145 | 145 |
| 146 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 146 virtual void OnWindowDestroyed(Window* window) override { |
| 147 EXPECT_FALSE(window_->parent()); | 147 EXPECT_FALSE(window_->parent()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 Window* window_; | 151 Window* window_; |
| 152 DISALLOW_COPY_AND_ASSIGN(DestroyOrphanDelegate); | 152 DISALLOW_COPY_AND_ASSIGN(DestroyOrphanDelegate); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Used in verifying mouse capture. | 155 // Used in verifying mouse capture. |
| 156 class CaptureWindowDelegateImpl : public TestWindowDelegate { | 156 class CaptureWindowDelegateImpl : public TestWindowDelegate { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 int capture_changed_event_count() const { | 170 int capture_changed_event_count() const { |
| 171 return capture_changed_event_count_; | 171 return capture_changed_event_count_; |
| 172 } | 172 } |
| 173 int capture_lost_count() const { return capture_lost_count_; } | 173 int capture_lost_count() const { return capture_lost_count_; } |
| 174 int mouse_event_count() const { return mouse_event_count_; } | 174 int mouse_event_count() const { return mouse_event_count_; } |
| 175 int touch_event_count() const { return touch_event_count_; } | 175 int touch_event_count() const { return touch_event_count_; } |
| 176 int gesture_event_count() const { return gesture_event_count_; } | 176 int gesture_event_count() const { return gesture_event_count_; } |
| 177 | 177 |
| 178 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 178 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 179 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) | 179 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) |
| 180 capture_changed_event_count_++; | 180 capture_changed_event_count_++; |
| 181 mouse_event_count_++; | 181 mouse_event_count_++; |
| 182 } | 182 } |
| 183 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 183 virtual void OnTouchEvent(ui::TouchEvent* event) override { |
| 184 touch_event_count_++; | 184 touch_event_count_++; |
| 185 } | 185 } |
| 186 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 186 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 187 gesture_event_count_++; | 187 gesture_event_count_++; |
| 188 } | 188 } |
| 189 virtual void OnCaptureLost() OVERRIDE { | 189 virtual void OnCaptureLost() override { |
| 190 capture_lost_count_++; | 190 capture_lost_count_++; |
| 191 } | 191 } |
| 192 | 192 |
| 193 private: | 193 private: |
| 194 int capture_changed_event_count_; | 194 int capture_changed_event_count_; |
| 195 int capture_lost_count_; | 195 int capture_lost_count_; |
| 196 int mouse_event_count_; | 196 int mouse_event_count_; |
| 197 int touch_event_count_; | 197 int touch_event_count_; |
| 198 int gesture_event_count_; | 198 int gesture_event_count_; |
| 199 | 199 |
| 200 DISALLOW_COPY_AND_ASSIGN(CaptureWindowDelegateImpl); | 200 DISALLOW_COPY_AND_ASSIGN(CaptureWindowDelegateImpl); |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 // Keeps track of the location of the gesture. | 203 // Keeps track of the location of the gesture. |
| 204 class GestureTrackPositionDelegate : public TestWindowDelegate { | 204 class GestureTrackPositionDelegate : public TestWindowDelegate { |
| 205 public: | 205 public: |
| 206 GestureTrackPositionDelegate() {} | 206 GestureTrackPositionDelegate() {} |
| 207 | 207 |
| 208 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 208 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 209 position_ = event->location(); | 209 position_ = event->location(); |
| 210 event->StopPropagation(); | 210 event->StopPropagation(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 const gfx::Point& position() const { return position_; } | 213 const gfx::Point& position() const { return position_; } |
| 214 | 214 |
| 215 private: | 215 private: |
| 216 gfx::Point position_; | 216 gfx::Point position_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(GestureTrackPositionDelegate); | 218 DISALLOW_COPY_AND_ASSIGN(GestureTrackPositionDelegate); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 base::TimeDelta getTime() { | 221 base::TimeDelta getTime() { |
| 222 return ui::EventTimeForNow(); | 222 return ui::EventTimeForNow(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 class SelfEventHandlingWindowDelegate : public TestWindowDelegate { | 225 class SelfEventHandlingWindowDelegate : public TestWindowDelegate { |
| 226 public: | 226 public: |
| 227 SelfEventHandlingWindowDelegate() {} | 227 SelfEventHandlingWindowDelegate() {} |
| 228 | 228 |
| 229 virtual bool ShouldDescendIntoChildForEventHandling( | 229 virtual bool ShouldDescendIntoChildForEventHandling( |
| 230 Window* child, | 230 Window* child, |
| 231 const gfx::Point& location) OVERRIDE { | 231 const gfx::Point& location) override { |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 | 234 |
| 235 private: | 235 private: |
| 236 DISALLOW_COPY_AND_ASSIGN(SelfEventHandlingWindowDelegate); | 236 DISALLOW_COPY_AND_ASSIGN(SelfEventHandlingWindowDelegate); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 // The delegate deletes itself when the window is being destroyed. | 239 // The delegate deletes itself when the window is being destroyed. |
| 240 class DestroyWindowDelegate : public TestWindowDelegate { | 240 class DestroyWindowDelegate : public TestWindowDelegate { |
| 241 public: | 241 public: |
| 242 DestroyWindowDelegate() {} | 242 DestroyWindowDelegate() {} |
| 243 | 243 |
| 244 private: | 244 private: |
| 245 virtual ~DestroyWindowDelegate() {} | 245 virtual ~DestroyWindowDelegate() {} |
| 246 | 246 |
| 247 // Overridden from WindowDelegate. | 247 // Overridden from WindowDelegate. |
| 248 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 248 virtual void OnWindowDestroyed(Window* window) override { |
| 249 delete this; | 249 delete this; |
| 250 } | 250 } |
| 251 | 251 |
| 252 DISALLOW_COPY_AND_ASSIGN(DestroyWindowDelegate); | 252 DISALLOW_COPY_AND_ASSIGN(DestroyWindowDelegate); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 } // namespace | 255 } // namespace |
| 256 | 256 |
| 257 TEST_F(WindowTest, GetChildById) { | 257 TEST_F(WindowTest, GetChildById) { |
| 258 scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); | 258 scoped_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 EXPECT_TRUE(w1->GetToplevelWindow() == NULL); | 569 EXPECT_TRUE(w1->GetToplevelWindow() == NULL); |
| 570 EXPECT_EQ(w11.get(), w11->GetToplevelWindow()); | 570 EXPECT_EQ(w11.get(), w11->GetToplevelWindow()); |
| 571 EXPECT_EQ(w11.get(), w111->GetToplevelWindow()); | 571 EXPECT_EQ(w11.get(), w111->GetToplevelWindow()); |
| 572 EXPECT_EQ(w11.get(), w1111->GetToplevelWindow()); | 572 EXPECT_EQ(w11.get(), w1111->GetToplevelWindow()); |
| 573 } | 573 } |
| 574 | 574 |
| 575 class AddedToRootWindowObserver : public WindowObserver { | 575 class AddedToRootWindowObserver : public WindowObserver { |
| 576 public: | 576 public: |
| 577 AddedToRootWindowObserver() : called_(false) {} | 577 AddedToRootWindowObserver() : called_(false) {} |
| 578 | 578 |
| 579 virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE { | 579 virtual void OnWindowAddedToRootWindow(Window* window) override { |
| 580 called_ = true; | 580 called_ = true; |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool called() const { return called_; } | 583 bool called() const { return called_; } |
| 584 | 584 |
| 585 private: | 585 private: |
| 586 bool called_; | 586 bool called_; |
| 587 | 587 |
| 588 DISALLOW_COPY_AND_ASSIGN(AddedToRootWindowObserver); | 588 DISALLOW_COPY_AND_ASSIGN(AddedToRootWindowObserver); |
| 589 }; | 589 }; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 // The |child| window is moved to the 0,0 in screen coordinates. | 1080 // The |child| window is moved to the 0,0 in screen coordinates. |
| 1081 // |GetBoundsInRootWindow()| should return 0,0. | 1081 // |GetBoundsInRootWindow()| should return 0,0. |
| 1082 child->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1082 child->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1083 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); | 1083 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 class MouseEnterExitWindowDelegate : public TestWindowDelegate { | 1086 class MouseEnterExitWindowDelegate : public TestWindowDelegate { |
| 1087 public: | 1087 public: |
| 1088 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} | 1088 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} |
| 1089 | 1089 |
| 1090 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1090 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 1091 switch (event->type()) { | 1091 switch (event->type()) { |
| 1092 case ui::ET_MOUSE_ENTERED: | 1092 case ui::ET_MOUSE_ENTERED: |
| 1093 EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED); | 1093 EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED); |
| 1094 entered_ = true; | 1094 entered_ = true; |
| 1095 break; | 1095 break; |
| 1096 case ui::ET_MOUSE_EXITED: | 1096 case ui::ET_MOUSE_EXITED: |
| 1097 EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED); | 1097 EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED); |
| 1098 exited_ = true; | 1098 exited_ = true; |
| 1099 break; | 1099 break; |
| 1100 default: | 1100 default: |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 hidden_(0) { | 1365 hidden_(0) { |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 int shown() const { return shown_; } | 1368 int shown() const { return shown_; } |
| 1369 int hidden() const { return hidden_; } | 1369 int hidden() const { return hidden_; } |
| 1370 void Clear() { | 1370 void Clear() { |
| 1371 shown_ = 0; | 1371 shown_ = 0; |
| 1372 hidden_ = 0; | 1372 hidden_ = 0; |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE { | 1375 virtual void OnWindowTargetVisibilityChanged(bool visible) override { |
| 1376 if (visible) | 1376 if (visible) |
| 1377 shown_++; | 1377 shown_++; |
| 1378 else | 1378 else |
| 1379 hidden_++; | 1379 hidden_++; |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 private: | 1382 private: |
| 1383 int shown_; | 1383 int shown_; |
| 1384 int hidden_; | 1384 int hidden_; |
| 1385 | 1385 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 transform_notifications_.begin(); | 1714 transform_notifications_.begin(); |
| 1715 it != transform_notifications_.end(); | 1715 it != transform_notifications_.end(); |
| 1716 ++it) { | 1716 ++it) { |
| 1717 base::StringAppendF(&result, "(%d,%d)", it->first, it->second); | 1717 base::StringAppendF(&result, "(%d,%d)", it->first, it->second); |
| 1718 } | 1718 } |
| 1719 transform_notifications_.clear(); | 1719 transform_notifications_.clear(); |
| 1720 return result; | 1720 return result; |
| 1721 } | 1721 } |
| 1722 | 1722 |
| 1723 private: | 1723 private: |
| 1724 virtual void OnWindowAdded(Window* new_window) OVERRIDE { | 1724 virtual void OnWindowAdded(Window* new_window) override { |
| 1725 added_count_++; | 1725 added_count_++; |
| 1726 } | 1726 } |
| 1727 | 1727 |
| 1728 virtual void OnWillRemoveWindow(Window* window) OVERRIDE { | 1728 virtual void OnWillRemoveWindow(Window* window) override { |
| 1729 removed_count_++; | 1729 removed_count_++; |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 virtual void OnWindowVisibilityChanged(Window* window, | 1732 virtual void OnWindowVisibilityChanged(Window* window, |
| 1733 bool visible) OVERRIDE { | 1733 bool visible) override { |
| 1734 if (!visibility_info_) { | 1734 if (!visibility_info_) { |
| 1735 visibility_info_.reset(new VisibilityInfo); | 1735 visibility_info_.reset(new VisibilityInfo); |
| 1736 visibility_info_->changed_count = 0; | 1736 visibility_info_->changed_count = 0; |
| 1737 } | 1737 } |
| 1738 visibility_info_->window_visible = window->IsVisible(); | 1738 visibility_info_->window_visible = window->IsVisible(); |
| 1739 visibility_info_->visible_param = visible; | 1739 visibility_info_->visible_param = visible; |
| 1740 visibility_info_->changed_count++; | 1740 visibility_info_->changed_count++; |
| 1741 } | 1741 } |
| 1742 | 1742 |
| 1743 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 1743 virtual void OnWindowDestroyed(Window* window) override { |
| 1744 EXPECT_FALSE(window->parent()); | 1744 EXPECT_FALSE(window->parent()); |
| 1745 destroyed_count_++; | 1745 destroyed_count_++; |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 virtual void OnWindowPropertyChanged(Window* window, | 1748 virtual void OnWindowPropertyChanged(Window* window, |
| 1749 const void* key, | 1749 const void* key, |
| 1750 intptr_t old) OVERRIDE { | 1750 intptr_t old) override { |
| 1751 property_key_ = key; | 1751 property_key_ = key; |
| 1752 old_property_value_ = old; | 1752 old_property_value_ = old; |
| 1753 } | 1753 } |
| 1754 | 1754 |
| 1755 virtual void OnAncestorWindowTransformed(Window* source, | 1755 virtual void OnAncestorWindowTransformed(Window* source, |
| 1756 Window* window) OVERRIDE { | 1756 Window* window) override { |
| 1757 transform_notifications_.push_back( | 1757 transform_notifications_.push_back( |
| 1758 std::make_pair(source->id(), window->id())); | 1758 std::make_pair(source->id(), window->id())); |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 int added_count_; | 1761 int added_count_; |
| 1762 int removed_count_; | 1762 int removed_count_; |
| 1763 int destroyed_count_; | 1763 int destroyed_count_; |
| 1764 scoped_ptr<VisibilityInfo> visibility_info_; | 1764 scoped_ptr<VisibilityInfo> visibility_info_; |
| 1765 const void* property_key_; | 1765 const void* property_key_; |
| 1766 intptr_t old_property_value_; | 1766 intptr_t old_property_value_; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 } | 2036 } |
| 2037 virtual ~TestVisibilityClient() { | 2037 virtual ~TestVisibilityClient() { |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 void set_ignore_visibility_changes(bool ignore_visibility_changes) { | 2040 void set_ignore_visibility_changes(bool ignore_visibility_changes) { |
| 2041 ignore_visibility_changes_ = ignore_visibility_changes; | 2041 ignore_visibility_changes_ = ignore_visibility_changes; |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 // Overridden from client::VisibilityClient: | 2044 // Overridden from client::VisibilityClient: |
| 2045 virtual void UpdateLayerVisibility(aura::Window* window, | 2045 virtual void UpdateLayerVisibility(aura::Window* window, |
| 2046 bool visible) OVERRIDE { | 2046 bool visible) override { |
| 2047 if (!ignore_visibility_changes_) | 2047 if (!ignore_visibility_changes_) |
| 2048 window->layer()->SetVisible(visible); | 2048 window->layer()->SetVisible(visible); |
| 2049 } | 2049 } |
| 2050 | 2050 |
| 2051 private: | 2051 private: |
| 2052 bool ignore_visibility_changes_; | 2052 bool ignore_visibility_changes_; |
| 2053 DISALLOW_COPY_AND_ASSIGN(TestVisibilityClient); | 2053 DISALLOW_COPY_AND_ASSIGN(TestVisibilityClient); |
| 2054 }; | 2054 }; |
| 2055 | 2055 |
| 2056 TEST_F(WindowTest, VisibilityClientIsVisible) { | 2056 TEST_F(WindowTest, VisibilityClientIsVisible) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 | 2172 |
| 2173 int added_count() const { return added_count_; } | 2173 int added_count() const { return added_count_; } |
| 2174 int removed_count() const { return removed_count_; } | 2174 int removed_count() const { return removed_count_; } |
| 2175 | 2175 |
| 2176 void Clear() { | 2176 void Clear() { |
| 2177 added_count_ = 0; | 2177 added_count_ = 0; |
| 2178 removed_count_ = 0; | 2178 removed_count_ = 0; |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 // Overridden from WindowObserver: | 2181 // Overridden from WindowObserver: |
| 2182 virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE { | 2182 virtual void OnWindowAddedToRootWindow(Window* window) override { |
| 2183 ++added_count_; | 2183 ++added_count_; |
| 2184 } | 2184 } |
| 2185 virtual void OnWindowRemovingFromRootWindow(Window* window, | 2185 virtual void OnWindowRemovingFromRootWindow(Window* window, |
| 2186 Window* new_root) OVERRIDE { | 2186 Window* new_root) override { |
| 2187 ++removed_count_; | 2187 ++removed_count_; |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 private: | 2190 private: |
| 2191 int added_count_; | 2191 int added_count_; |
| 2192 int removed_count_; | 2192 int removed_count_; |
| 2193 | 2193 |
| 2194 DISALLOW_COPY_AND_ASSIGN(RootWindowAttachmentObserver); | 2194 DISALLOW_COPY_AND_ASSIGN(RootWindowAttachmentObserver); |
| 2195 }; | 2195 }; |
| 2196 | 2196 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 EXPECT_EQ(2, observer.added_count()); | 2258 EXPECT_EQ(2, observer.added_count()); |
| 2259 EXPECT_EQ(2, observer.removed_count()); | 2259 EXPECT_EQ(2, observer.removed_count()); |
| 2260 } | 2260 } |
| 2261 | 2261 |
| 2262 class BoundsChangedWindowObserver : public WindowObserver { | 2262 class BoundsChangedWindowObserver : public WindowObserver { |
| 2263 public: | 2263 public: |
| 2264 BoundsChangedWindowObserver() : root_set_(false) {} | 2264 BoundsChangedWindowObserver() : root_set_(false) {} |
| 2265 | 2265 |
| 2266 virtual void OnWindowBoundsChanged(Window* window, | 2266 virtual void OnWindowBoundsChanged(Window* window, |
| 2267 const gfx::Rect& old_bounds, | 2267 const gfx::Rect& old_bounds, |
| 2268 const gfx::Rect& new_bounds) OVERRIDE { | 2268 const gfx::Rect& new_bounds) override { |
| 2269 root_set_ = window->GetRootWindow() != NULL; | 2269 root_set_ = window->GetRootWindow() != NULL; |
| 2270 } | 2270 } |
| 2271 | 2271 |
| 2272 bool root_set() const { return root_set_; } | 2272 bool root_set() const { return root_set_; } |
| 2273 | 2273 |
| 2274 private: | 2274 private: |
| 2275 bool root_set_; | 2275 bool root_set_; |
| 2276 | 2276 |
| 2277 DISALLOW_COPY_AND_ASSIGN(BoundsChangedWindowObserver); | 2277 DISALLOW_COPY_AND_ASSIGN(BoundsChangedWindowObserver); |
| 2278 }; | 2278 }; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 // Used By DeleteWindowFromOnWindowDestroyed. Destroys a Window from | 2337 // Used By DeleteWindowFromOnWindowDestroyed. Destroys a Window from |
| 2338 // OnWindowDestroyed(). | 2338 // OnWindowDestroyed(). |
| 2339 class OwningWindowDelegate : public TestWindowDelegate { | 2339 class OwningWindowDelegate : public TestWindowDelegate { |
| 2340 public: | 2340 public: |
| 2341 OwningWindowDelegate() {} | 2341 OwningWindowDelegate() {} |
| 2342 | 2342 |
| 2343 void SetOwnedWindow(Window* window) { | 2343 void SetOwnedWindow(Window* window) { |
| 2344 owned_window_.reset(window); | 2344 owned_window_.reset(window); |
| 2345 } | 2345 } |
| 2346 | 2346 |
| 2347 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 2347 virtual void OnWindowDestroyed(Window* window) override { |
| 2348 owned_window_.reset(NULL); | 2348 owned_window_.reset(NULL); |
| 2349 } | 2349 } |
| 2350 | 2350 |
| 2351 private: | 2351 private: |
| 2352 scoped_ptr<Window> owned_window_; | 2352 scoped_ptr<Window> owned_window_; |
| 2353 | 2353 |
| 2354 DISALLOW_COPY_AND_ASSIGN(OwningWindowDelegate); | 2354 DISALLOW_COPY_AND_ASSIGN(OwningWindowDelegate); |
| 2355 }; | 2355 }; |
| 2356 | 2356 |
| 2357 } // namespace | 2357 } // namespace |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2383 public: | 2383 public: |
| 2384 BoundsChangeDelegate() : bounds_changed_(false) {} | 2384 BoundsChangeDelegate() : bounds_changed_(false) {} |
| 2385 | 2385 |
| 2386 void clear_bounds_changed() { bounds_changed_ = false; } | 2386 void clear_bounds_changed() { bounds_changed_ = false; } |
| 2387 bool bounds_changed() const { | 2387 bool bounds_changed() const { |
| 2388 return bounds_changed_; | 2388 return bounds_changed_; |
| 2389 } | 2389 } |
| 2390 | 2390 |
| 2391 // Window | 2391 // Window |
| 2392 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | 2392 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 2393 const gfx::Rect& new_bounds) OVERRIDE { | 2393 const gfx::Rect& new_bounds) override { |
| 2394 bounds_changed_ = true; | 2394 bounds_changed_ = true; |
| 2395 } | 2395 } |
| 2396 | 2396 |
| 2397 private: | 2397 private: |
| 2398 // Was OnBoundsChanged() invoked? | 2398 // Was OnBoundsChanged() invoked? |
| 2399 bool bounds_changed_; | 2399 bool bounds_changed_; |
| 2400 | 2400 |
| 2401 DISALLOW_COPY_AND_ASSIGN(BoundsChangeDelegate); | 2401 DISALLOW_COPY_AND_ASSIGN(BoundsChangeDelegate); |
| 2402 }; | 2402 }; |
| 2403 | 2403 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 AddChildNotificationsObserver() : added_count_(0), removed_count_(0) {} | 2491 AddChildNotificationsObserver() : added_count_(0), removed_count_(0) {} |
| 2492 | 2492 |
| 2493 std::string CountStringAndReset() { | 2493 std::string CountStringAndReset() { |
| 2494 std::string result = base::IntToString(added_count_) + " " + | 2494 std::string result = base::IntToString(added_count_) + " " + |
| 2495 base::IntToString(removed_count_); | 2495 base::IntToString(removed_count_); |
| 2496 added_count_ = removed_count_ = 0; | 2496 added_count_ = removed_count_ = 0; |
| 2497 return result; | 2497 return result; |
| 2498 } | 2498 } |
| 2499 | 2499 |
| 2500 // WindowObserver overrides: | 2500 // WindowObserver overrides: |
| 2501 virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE { | 2501 virtual void OnWindowAddedToRootWindow(Window* window) override { |
| 2502 added_count_++; | 2502 added_count_++; |
| 2503 } | 2503 } |
| 2504 virtual void OnWindowRemovingFromRootWindow(Window* window, | 2504 virtual void OnWindowRemovingFromRootWindow(Window* window, |
| 2505 Window* new_root) OVERRIDE { | 2505 Window* new_root) override { |
| 2506 removed_count_++; | 2506 removed_count_++; |
| 2507 } | 2507 } |
| 2508 | 2508 |
| 2509 private: | 2509 private: |
| 2510 int added_count_; | 2510 int added_count_; |
| 2511 int removed_count_; | 2511 int removed_count_; |
| 2512 | 2512 |
| 2513 DISALLOW_COPY_AND_ASSIGN(AddChildNotificationsObserver); | 2513 DISALLOW_COPY_AND_ASSIGN(AddChildNotificationsObserver); |
| 2514 }; | 2514 }; |
| 2515 | 2515 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 ParamsMatch(params_[index], params); | 2557 ParamsMatch(params_[index], params); |
| 2558 } | 2558 } |
| 2559 | 2559 |
| 2560 void Reset() { | 2560 void Reset() { |
| 2561 params_.clear(); | 2561 params_.clear(); |
| 2562 } | 2562 } |
| 2563 | 2563 |
| 2564 private: | 2564 private: |
| 2565 // Overridden from WindowObserver: | 2565 // Overridden from WindowObserver: |
| 2566 virtual void OnWindowHierarchyChanging( | 2566 virtual void OnWindowHierarchyChanging( |
| 2567 const HierarchyChangeParams& params) OVERRIDE { | 2567 const HierarchyChangeParams& params) override { |
| 2568 params_.push_back(params); | 2568 params_.push_back(params); |
| 2569 } | 2569 } |
| 2570 virtual void OnWindowHierarchyChanged( | 2570 virtual void OnWindowHierarchyChanged( |
| 2571 const HierarchyChangeParams& params) OVERRIDE { | 2571 const HierarchyChangeParams& params) override { |
| 2572 params_.push_back(params); | 2572 params_.push_back(params); |
| 2573 } | 2573 } |
| 2574 | 2574 |
| 2575 void ParamsMatch(const WindowObserver::HierarchyChangeParams& p1, | 2575 void ParamsMatch(const WindowObserver::HierarchyChangeParams& p1, |
| 2576 const WindowObserver::HierarchyChangeParams& p2) const { | 2576 const WindowObserver::HierarchyChangeParams& p2) const { |
| 2577 EXPECT_EQ(p1.phase, p2.phase); | 2577 EXPECT_EQ(p1.phase, p2.phase); |
| 2578 EXPECT_EQ(p1.target, p2.target); | 2578 EXPECT_EQ(p1.target, p2.target); |
| 2579 EXPECT_EQ(p1.new_parent, p2.new_parent); | 2579 EXPECT_EQ(p1.new_parent, p2.new_parent); |
| 2580 EXPECT_EQ(p1.old_parent, p2.old_parent); | 2580 EXPECT_EQ(p1.old_parent, p2.old_parent); |
| 2581 EXPECT_EQ(p1.receiver, p2.receiver); | 2581 EXPECT_EQ(p1.receiver, p2.receiver); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 } | 2942 } |
| 2943 | 2943 |
| 2944 const gfx::Vector2d& most_recent_paint_matrix_offset() const { | 2944 const gfx::Vector2d& most_recent_paint_matrix_offset() const { |
| 2945 return most_recent_paint_matrix_offset_; | 2945 return most_recent_paint_matrix_offset_; |
| 2946 } | 2946 } |
| 2947 | 2947 |
| 2948 void clear_paint_count() { paint_count_ = 0; } | 2948 void clear_paint_count() { paint_count_ = 0; } |
| 2949 int paint_count() const { return paint_count_; } | 2949 int paint_count() const { return paint_count_; } |
| 2950 | 2950 |
| 2951 // TestWindowDelegate:: | 2951 // TestWindowDelegate:: |
| 2952 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 2952 virtual void OnPaint(gfx::Canvas* canvas) override { |
| 2953 paint_count_++; | 2953 paint_count_++; |
| 2954 canvas->GetClipBounds(&most_recent_paint_clip_bounds_); | 2954 canvas->GetClipBounds(&most_recent_paint_clip_bounds_); |
| 2955 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); | 2955 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); |
| 2956 most_recent_paint_matrix_offset_ = gfx::Vector2d( | 2956 most_recent_paint_matrix_offset_ = gfx::Vector2d( |
| 2957 SkScalarFloorToInt(matrix.getTranslateX()), | 2957 SkScalarFloorToInt(matrix.getTranslateX()), |
| 2958 SkScalarFloorToInt(matrix.getTranslateY())); | 2958 SkScalarFloorToInt(matrix.getTranslateY())); |
| 2959 } | 2959 } |
| 2960 | 2960 |
| 2961 private: | 2961 private: |
| 2962 int paint_count_; | 2962 int paint_count_; |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 bool animation_aborted() const { return animation_aborted_; } | 3418 bool animation_aborted() const { return animation_aborted_; } |
| 3419 | 3419 |
| 3420 void Reset() { | 3420 void Reset() { |
| 3421 animation_completed_ = false; | 3421 animation_completed_ = false; |
| 3422 animation_aborted_ = false; | 3422 animation_aborted_ = false; |
| 3423 } | 3423 } |
| 3424 | 3424 |
| 3425 private: | 3425 private: |
| 3426 // ui::LayerAnimationObserver: | 3426 // ui::LayerAnimationObserver: |
| 3427 virtual void OnLayerAnimationEnded( | 3427 virtual void OnLayerAnimationEnded( |
| 3428 ui::LayerAnimationSequence* sequence) OVERRIDE { | 3428 ui::LayerAnimationSequence* sequence) override { |
| 3429 animation_completed_ = true; | 3429 animation_completed_ = true; |
| 3430 } | 3430 } |
| 3431 | 3431 |
| 3432 virtual void OnLayerAnimationAborted( | 3432 virtual void OnLayerAnimationAborted( |
| 3433 ui::LayerAnimationSequence* sequence) OVERRIDE { | 3433 ui::LayerAnimationSequence* sequence) override { |
| 3434 animation_aborted_ = true; | 3434 animation_aborted_ = true; |
| 3435 } | 3435 } |
| 3436 | 3436 |
| 3437 virtual void OnLayerAnimationScheduled( | 3437 virtual void OnLayerAnimationScheduled( |
| 3438 ui::LayerAnimationSequence* sequence) OVERRIDE { | 3438 ui::LayerAnimationSequence* sequence) override { |
| 3439 } | 3439 } |
| 3440 | 3440 |
| 3441 bool animation_completed_; | 3441 bool animation_completed_; |
| 3442 bool animation_aborted_; | 3442 bool animation_aborted_; |
| 3443 | 3443 |
| 3444 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationObserver); | 3444 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationObserver); |
| 3445 }; | 3445 }; |
| 3446 | 3446 |
| 3447 } | 3447 } |
| 3448 | 3448 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3490 | 3490 |
| 3491 EXPECT_TRUE(animator.get()); | 3491 EXPECT_TRUE(animator.get()); |
| 3492 EXPECT_FALSE(animator->is_animating()); | 3492 EXPECT_FALSE(animator->is_animating()); |
| 3493 EXPECT_TRUE(observer.animation_completed()); | 3493 EXPECT_TRUE(observer.animation_completed()); |
| 3494 EXPECT_FALSE(observer.animation_aborted()); | 3494 EXPECT_FALSE(observer.animation_aborted()); |
| 3495 animator->RemoveObserver(&observer); | 3495 animator->RemoveObserver(&observer); |
| 3496 } | 3496 } |
| 3497 | 3497 |
| 3498 } // namespace test | 3498 } // namespace test |
| 3499 } // namespace aura | 3499 } // namespace aura |
| OLD | NEW |