| Index: ash/wm/partial_screenshot_view_unittest.cc
|
| diff --git a/ash/wm/partial_screenshot_view_unittest.cc b/ash/wm/partial_screenshot_view_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94ca066caa3707fe6d4320a9e7fda1d4c80854cb
|
| --- /dev/null
|
| +++ b/ash/wm/partial_screenshot_view_unittest.cc
|
| @@ -0,0 +1,101 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/wm/partial_screenshot_view.h"
|
| +
|
| +#include "ash/screenshot_delegate.h"
|
| +#include "ash/shell.h"
|
| +#include "ash/shell_window_ids.h"
|
| +#include "ash/test/ash_test_base.h"
|
| +#include "ui/aura/root_window.h"
|
| +#include "ui/aura/test/event_generator.h"
|
| +
|
| +namespace ash {
|
| +
|
| +class FakeScreenshotDelegate : public ScreenshotDelegate {
|
| + public:
|
| + FakeScreenshotDelegate() : screenshot_count_(0) {}
|
| +
|
| + void HandleTakeScreenshotForAllRootWindows() {}
|
| + void HandleTakePartialScreenshot(aura::Window* window,
|
| + const gfx::Rect& rect) {
|
| + rect_ = rect;
|
| + screenshot_count_++;
|
| + }
|
| +
|
| + bool CanTakeScreenshot() {
|
| + return true;
|
| + }
|
| +
|
| + gfx::Rect rect_;
|
| + int screenshot_count_;
|
| +};
|
| +
|
| +class PartialScreenshotViewTest : public test::AshTestBase {
|
| + public:
|
| + PartialScreenshotViewTest() : view_(NULL) {}
|
| + virtual ~PartialScreenshotViewTest() {}
|
| +
|
| + virtual void SetUp() OVERRIDE {
|
| + test::AshTestBase::SetUp();
|
| + delegate_.reset(new FakeScreenshotDelegate());
|
| + std::vector<PartialScreenshotView*> views =
|
| + PartialScreenshotView::StartPartialScreenshot(delegate_.get());
|
| + DCHECK(!views.empty());
|
| + view_ = views[0];
|
| + }
|
| +
|
| + virtual void TearDown() OVERRIDE {
|
| + test::AshTestBase::TearDown();
|
| + }
|
| +
|
| + protected:
|
| + PartialScreenshotView* view_;
|
| + scoped_ptr<FakeScreenshotDelegate> delegate_;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest);
|
| +};
|
| +
|
| +TEST_F(PartialScreenshotViewTest, BasicMouse) {
|
| + aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
|
| +
|
| + generator.MoveMouseTo(100, 100);
|
| + generator.PressLeftButton();
|
| + EXPECT_FALSE(view_->is_dragging_);
|
| + EXPECT_EQ("100,100", view_->start_position_.ToString());
|
| +
|
| + generator.MoveMouseTo(200, 200);
|
| + EXPECT_TRUE(view_->is_dragging_);
|
| + EXPECT_EQ("200,200", view_->current_position_.ToString());
|
| +
|
| + generator.ReleaseLeftButton();
|
| + EXPECT_FALSE(view_->is_dragging_);
|
| + EXPECT_EQ("100,100 100x100", delegate_->rect_.ToString());
|
| + EXPECT_EQ(1, delegate_->screenshot_count_);
|
| +}
|
| +
|
| +TEST_F(PartialScreenshotViewTest, BasicTouch) {
|
| + aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
|
| +
|
| + generator.set_current_location(gfx::Point(100,100));
|
| + generator.GestureTapDownAndUp(gfx::Point(100,100));
|
| + EXPECT_FALSE(view_->is_dragging_);
|
| + EXPECT_EQ(0, delegate_->screenshot_count_);
|
| +
|
| + generator.PressTouch();
|
| + EXPECT_FALSE(view_->is_dragging_);
|
| + EXPECT_EQ("100,100", view_->start_position_.ToString());
|
| +
|
| + generator.MoveTouch(gfx::Point(200, 200));
|
| + EXPECT_TRUE(view_->is_dragging_);
|
| + EXPECT_EQ("200,200", view_->current_position_.ToString());
|
| +
|
| + generator.ReleaseTouch();
|
| + EXPECT_FALSE(view_->is_dragging_);
|
| + EXPECT_EQ(1, delegate_->screenshot_count_);
|
| + EXPECT_EQ("100,100 100x100", delegate_->rect_.ToString());
|
| +}
|
| +
|
| +} // namespace ash
|
|
|