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 "ash/wm/partial_screenshot_view.h" | 5 #include "ash/wm/partial_screenshot_view.h" |
6 | 6 |
7 #include "ash/screenshot_delegate.h" | 7 #include "ash/screenshot_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
11 #include "ash/test/test_screenshot_delegate.h" | 11 #include "ash/test/test_screenshot_delegate.h" |
12 #include "ui/aura/test/event_generator.h" | |
13 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
| 13 #include "ui/events/test/event_generator.h" |
14 | 14 |
15 namespace ash { | 15 namespace ash { |
16 | 16 |
17 class PartialScreenshotViewTest : public test::AshTestBase { | 17 class PartialScreenshotViewTest : public test::AshTestBase { |
18 public: | 18 public: |
19 PartialScreenshotViewTest() : view_(NULL) {} | 19 PartialScreenshotViewTest() : view_(NULL) {} |
20 virtual ~PartialScreenshotViewTest() {} | 20 virtual ~PartialScreenshotViewTest() {} |
21 | 21 |
22 virtual void SetUp() OVERRIDE { | 22 virtual void SetUp() OVERRIDE { |
23 test::AshTestBase::SetUp(); | 23 test::AshTestBase::SetUp(); |
24 std::vector<PartialScreenshotView*> views = | 24 std::vector<PartialScreenshotView*> views = |
25 PartialScreenshotView::StartPartialScreenshot(GetScreenshotDelegate()); | 25 PartialScreenshotView::StartPartialScreenshot(GetScreenshotDelegate()); |
26 ASSERT_EQ(1u, views.size()); | 26 ASSERT_EQ(1u, views.size()); |
27 view_ = views[0]; | 27 view_ = views[0]; |
28 } | 28 } |
29 | 29 |
30 protected: | 30 protected: |
31 PartialScreenshotView* view_; | 31 PartialScreenshotView* view_; |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest); | 34 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest); |
35 }; | 35 }; |
36 | 36 |
37 TEST_F(PartialScreenshotViewTest, BasicMouse) { | 37 TEST_F(PartialScreenshotViewTest, BasicMouse) { |
38 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 38 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
39 | 39 |
40 generator.MoveMouseTo(100, 100); | 40 generator.MoveMouseTo(100, 100); |
41 generator.PressLeftButton(); | 41 generator.PressLeftButton(); |
42 EXPECT_FALSE(view_->is_dragging_); | 42 EXPECT_FALSE(view_->is_dragging_); |
43 EXPECT_EQ("100,100", view_->start_position_.ToString()); | 43 EXPECT_EQ("100,100", view_->start_position_.ToString()); |
44 | 44 |
45 generator.MoveMouseTo(200, 200); | 45 generator.MoveMouseTo(200, 200); |
46 EXPECT_TRUE(view_->is_dragging_); | 46 EXPECT_TRUE(view_->is_dragging_); |
47 EXPECT_EQ("200,200", view_->current_position_.ToString()); | 47 EXPECT_EQ("200,200", view_->current_position_.ToString()); |
48 | 48 |
49 generator.ReleaseLeftButton(); | 49 generator.ReleaseLeftButton(); |
50 EXPECT_FALSE(view_->is_dragging_); | 50 EXPECT_FALSE(view_->is_dragging_); |
51 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString()); | 51 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString()); |
52 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); | 52 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); |
53 } | 53 } |
54 | 54 |
55 TEST_F(PartialScreenshotViewTest, BasicTouch) { | 55 TEST_F(PartialScreenshotViewTest, BasicTouch) { |
56 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 56 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
57 | 57 |
58 generator.set_current_location(gfx::Point(100,100)); | 58 generator.set_current_location(gfx::Point(100,100)); |
59 generator.GestureTapDownAndUp(gfx::Point(100,100)); | 59 generator.GestureTapDownAndUp(gfx::Point(100,100)); |
60 EXPECT_FALSE(view_->is_dragging_); | 60 EXPECT_FALSE(view_->is_dragging_); |
61 EXPECT_EQ(0, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); | 61 EXPECT_EQ(0, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); |
62 | 62 |
63 generator.PressTouch(); | 63 generator.PressTouch(); |
64 EXPECT_FALSE(view_->is_dragging_); | 64 EXPECT_FALSE(view_->is_dragging_); |
65 EXPECT_EQ("100,100", view_->start_position_.ToString()); | 65 EXPECT_EQ("100,100", view_->start_position_.ToString()); |
66 | 66 |
67 generator.MoveTouch(gfx::Point(200, 200)); | 67 generator.MoveTouch(gfx::Point(200, 200)); |
68 EXPECT_TRUE(view_->is_dragging_); | 68 EXPECT_TRUE(view_->is_dragging_); |
69 EXPECT_EQ("200,200", view_->current_position_.ToString()); | 69 EXPECT_EQ("200,200", view_->current_position_.ToString()); |
70 | 70 |
71 generator.ReleaseTouch(); | 71 generator.ReleaseTouch(); |
72 EXPECT_FALSE(view_->is_dragging_); | 72 EXPECT_FALSE(view_->is_dragging_); |
73 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); | 73 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); |
74 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString()); | 74 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString()); |
75 } | 75 } |
76 | 76 |
77 } // namespace ash | 77 } // namespace ash |
OLD | NEW |