Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Side by Side Diff: ash/wm/partial_screenshot_view_unittest.cc

Issue 13006010: Add support for taking partial screenshot using touch (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ash/wm/partial_screenshot_view.h"
6
7 #include "ash/screenshot_delegate.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ui/aura/root_window.h"
12 #include "ui/aura/test/event_generator.h"
13
14 namespace ash {
15
16 class FakeScreenshotDelegate : public ScreenshotDelegate {
17 public:
18 FakeScreenshotDelegate() : screenshot_count_(0) {}
19
20 void HandleTakeScreenshotForAllRootWindows() {}
21 void HandleTakePartialScreenshot(aura::Window* window,
22 const gfx::Rect& rect) {
23 rect_ = rect;
24 screenshot_count_++;
25 }
26
27 bool CanTakeScreenshot() {
28 return true;
29 }
30
31 gfx::Rect rect_;
32 int screenshot_count_;
33 };
34
35 class PartialScreenshotViewTest : public test::AshTestBase {
36 public:
37 PartialScreenshotViewTest() : view_(NULL) {}
38 virtual ~PartialScreenshotViewTest() {}
39
40 virtual void SetUp() OVERRIDE {
41 test::AshTestBase::SetUp();
42 delegate_.reset(new FakeScreenshotDelegate());
43 std::vector<PartialScreenshotView*> views =
44 PartialScreenshotView::StartPartialScreenshot(delegate_.get());
45 DCHECK(!views.empty());
46 view_ = views[0];
47 }
48
49 virtual void TearDown() OVERRIDE {
50 test::AshTestBase::TearDown();
51 }
52
53 protected:
54 PartialScreenshotView* view_;
55 scoped_ptr<FakeScreenshotDelegate> delegate_;
56
57 private:
58 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest);
59 };
60
61 TEST_F(PartialScreenshotViewTest, BasicMouse) {
62 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
63
64 generator.MoveMouseTo(100, 100);
65 generator.PressLeftButton();
66 EXPECT_FALSE(view_->is_dragging_);
67 EXPECT_EQ("100,100", view_->start_position_.ToString());
68
69 generator.MoveMouseTo(200, 200);
70 EXPECT_TRUE(view_->is_dragging_);
71 EXPECT_EQ("200,200", view_->current_position_.ToString());
72
73 generator.ReleaseLeftButton();
74 EXPECT_FALSE(view_->is_dragging_);
75 EXPECT_EQ("100,100 100x100", delegate_->rect_.ToString());
76 EXPECT_EQ(1, delegate_->screenshot_count_);
77 }
78
79 TEST_F(PartialScreenshotViewTest, BasicTouch) {
80 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
81
82 generator.set_current_location(gfx::Point(100,100));
83 generator.GestureTapDownAndUp(gfx::Point(100,100));
84 EXPECT_FALSE(view_->is_dragging_);
85 EXPECT_EQ(0, delegate_->screenshot_count_);
86
87 generator.PressTouch();
88 EXPECT_FALSE(view_->is_dragging_);
89 EXPECT_EQ("100,100", view_->start_position_.ToString());
90
91 generator.MoveTouch(gfx::Point(200, 200));
92 EXPECT_TRUE(view_->is_dragging_);
93 EXPECT_EQ("200,200", view_->current_position_.ToString());
94
95 generator.ReleaseTouch();
96 EXPECT_FALSE(view_->is_dragging_);
97 EXPECT_EQ(1, delegate_->screenshot_count_);
98 EXPECT_EQ("100,100 100x100", delegate_->rect_.ToString());
99 }
100
101 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698