| 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 "content/browser/web_contents/aura/window_slider.h" | 5 #include "content/browser/web_contents/aura/window_slider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
| 10 #include "ui/aura/test/event_generator.h" | 10 #include "ui/aura/test/event_generator.h" |
| 11 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | |
| 14 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 14 #include "ui/events/event_processor.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 void DispatchEventDuringScrollCallback(aura::WindowEventDispatcher* dispatcher, | 18 void DispatchEventDuringScrollCallback(ui::EventProcessor* dispatcher, |
| 19 ui::Event* event, | 19 ui::Event* event, |
| 20 ui::EventType type, | 20 ui::EventType type, |
| 21 const gfx::Vector2dF& delta) { | 21 const gfx::Vector2dF& delta) { |
| 22 if (type != ui::ET_GESTURE_SCROLL_UPDATE) | 22 if (type != ui::ET_GESTURE_SCROLL_UPDATE) |
| 23 return; | 23 return; |
| 24 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(event); | 24 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(event); |
| 25 CHECK(!details.dispatcher_destroyed); | 25 CHECK(!details.dispatcher_destroyed); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ChangeSliderOwnerDuringScrollCallback(scoped_ptr<aura::Window>* window, | 28 void ChangeSliderOwnerDuringScrollCallback(scoped_ptr<aura::Window>* window, |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 new WindowSlider(&slider_delegate, root_window(), window.get()); | 258 new WindowSlider(&slider_delegate, root_window(), window.get()); |
| 259 for (int i = 0; events[i]; ++i) { | 259 for (int i = 0; events[i]; ++i) { |
| 260 // Generate a horizontal overscroll. | 260 // Generate a horizontal overscroll. |
| 261 aura::test::EventGenerator generator(root_window()); | 261 aura::test::EventGenerator generator(root_window()); |
| 262 generator.GestureScrollSequenceWithCallback( | 262 generator.GestureScrollSequenceWithCallback( |
| 263 gfx::Point(10, 10), | 263 gfx::Point(10, 10), |
| 264 gfx::Point(80, 10), | 264 gfx::Point(80, 10), |
| 265 base::TimeDelta::FromMilliseconds(10), | 265 base::TimeDelta::FromMilliseconds(10), |
| 266 1, | 266 1, |
| 267 base::Bind(&DispatchEventDuringScrollCallback, | 267 base::Bind(&DispatchEventDuringScrollCallback, |
| 268 root_window()->GetHost()->dispatcher(), | 268 root_window()->GetHost()->event_processor(), |
| 269 base::Owned(events[i]))); | 269 base::Owned(events[i]))); |
| 270 EXPECT_TRUE(slider_delegate.created_back_layer()); | 270 EXPECT_TRUE(slider_delegate.created_back_layer()); |
| 271 EXPECT_TRUE(slider_delegate.slide_aborted()); | 271 EXPECT_TRUE(slider_delegate.slide_aborted()); |
| 272 EXPECT_FALSE(slider_delegate.created_front_layer()); | 272 EXPECT_FALSE(slider_delegate.created_front_layer()); |
| 273 EXPECT_FALSE(slider_delegate.slide_completed()); | 273 EXPECT_FALSE(slider_delegate.slide_completed()); |
| 274 EXPECT_FALSE(slider_delegate.slider_destroyed()); | 274 EXPECT_FALSE(slider_delegate.slider_destroyed()); |
| 275 slider_delegate.Reset(); | 275 slider_delegate.Reset(); |
| 276 } | 276 } |
| 277 window.reset(); | 277 window.reset(); |
| 278 EXPECT_TRUE(slider_delegate.slider_destroyed()); | 278 EXPECT_TRUE(slider_delegate.slider_destroyed()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 EXPECT_FALSE(slider_delegate.created_front_layer()); | 400 EXPECT_FALSE(slider_delegate.created_front_layer()); |
| 401 EXPECT_FALSE(slider_delegate.slide_aborted()); | 401 EXPECT_FALSE(slider_delegate.slide_aborted()); |
| 402 EXPECT_TRUE(slider_delegate.slider_destroyed()); | 402 EXPECT_TRUE(slider_delegate.slider_destroyed()); |
| 403 | 403 |
| 404 // Destroying the slider would have destroyed |window| too. So |window| should | 404 // Destroying the slider would have destroyed |window| too. So |window| should |
| 405 // not need to be destroyed here. | 405 // not need to be destroyed here. |
| 406 EXPECT_EQ(child_windows, root_window()->children().size()); | 406 EXPECT_EQ(child_windows, root_window()->children().size()); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace content | 409 } // namespace content |
| OLD | NEW |