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
3 // found in the LICENSE file.
5 #include "ash/wm/partial_screenshot_view.h"
7 #include "ash/screenshot_delegate.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_screenshot_delegate.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/aura/test/event_generator.h"
17 class PartialScreenshotViewTest
: public test::AshTestBase
{
19 PartialScreenshotViewTest() : view_(NULL
) {}
20 virtual ~PartialScreenshotViewTest() {}
22 virtual void SetUp() OVERRIDE
{
23 test::AshTestBase::SetUp();
24 std::vector
<PartialScreenshotView
*> views
=
25 PartialScreenshotView::StartPartialScreenshot(GetScreenshotDelegate());
26 ASSERT_EQ(1u, views
.size());
31 PartialScreenshotView
* view_
;
34 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest
);
37 TEST_F(PartialScreenshotViewTest
, BasicMouse
) {
38 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow());
40 generator
.MoveMouseTo(100, 100);
41 generator
.PressLeftButton();
42 EXPECT_FALSE(view_
->is_dragging_
);
43 EXPECT_EQ("100,100", view_
->start_position_
.ToString());
45 generator
.MoveMouseTo(200, 200);
46 EXPECT_TRUE(view_
->is_dragging_
);
47 EXPECT_EQ("200,200", view_
->current_position_
.ToString());
49 generator
.ReleaseLeftButton();
50 EXPECT_FALSE(view_
->is_dragging_
);
51 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());
52 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());
55 TEST_F(PartialScreenshotViewTest
, BasicTouch
) {
56 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow());
58 generator
.set_current_location(gfx::Point(100,100));
59 generator
.GestureTapDownAndUp(gfx::Point(100,100));
60 EXPECT_FALSE(view_
->is_dragging_
);
61 EXPECT_EQ(0, GetScreenshotDelegate()->handle_take_partial_screenshot_count());
63 generator
.PressTouch();
64 EXPECT_FALSE(view_
->is_dragging_
);
65 EXPECT_EQ("100,100", view_
->start_position_
.ToString());
67 generator
.MoveTouch(gfx::Point(200, 200));
68 EXPECT_TRUE(view_
->is_dragging_
);
69 EXPECT_EQ("200,200", view_
->current_position_
.ToString());
71 generator
.ReleaseTouch();
72 EXPECT_FALSE(view_
->is_dragging_
);
73 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());
74 EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());