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

Unified Diff: ash/wm/partial_screenshot_view_unittest.cc

Issue 461093003: Fix the bug of multiple overlays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more tests Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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
index 3b763b42ff5045760a0dc723a2e1dabf67708da5..103d10a6b28d33e679ae4a100986484904f1a8d9 100644
--- a/ash/wm/partial_screenshot_view_unittest.cc
+++ b/ash/wm/partial_screenshot_view_unittest.cc
@@ -8,33 +8,51 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
+#include "ash/test/test_overlay_delegate.h"
#include "ash/test/test_screenshot_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/test/event_generator.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_observer.h"
namespace ash {
-class PartialScreenshotViewTest : public test::AshTestBase {
+class PartialScreenshotViewTest : public test::AshTestBase,
+ public views::WidgetObserver {
public:
PartialScreenshotViewTest() : view_(NULL) {}
- virtual ~PartialScreenshotViewTest() {}
+ virtual ~PartialScreenshotViewTest() {
+ if (view_)
+ view_->GetWidget()->RemoveObserver(this);
+ }
- virtual void SetUp() OVERRIDE {
- test::AshTestBase::SetUp();
+ void StartPartialScreenshot() {
std::vector<PartialScreenshotView*> views =
PartialScreenshotView::StartPartialScreenshot(GetScreenshotDelegate());
- ASSERT_EQ(1u, views.size());
- view_ = views[0];
+ if (!views.empty()) {
+ view_ = views[0];
+ view_->GetWidget()->AddObserver(this);
+ }
}
protected:
PartialScreenshotView* view_;
private:
+ // views::WidgetObserver:
+ virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE {
+ if (view_ && view_->GetWidget() == widget)
+ view_ = NULL;
+ widget->RemoveObserver(this);
+ }
+
DISALLOW_COPY_AND_ASSIGN(PartialScreenshotViewTest);
};
TEST_F(PartialScreenshotViewTest, BasicMouse) {
+ StartPartialScreenshot();
+ ASSERT_TRUE(view_);
+
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.MoveMouseTo(100, 100);
@@ -53,6 +71,9 @@ TEST_F(PartialScreenshotViewTest, BasicMouse) {
}
TEST_F(PartialScreenshotViewTest, BasicTouch) {
+ StartPartialScreenshot();
+ ASSERT_TRUE(view_);
+
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.set_current_location(gfx::Point(100,100));
@@ -74,4 +95,29 @@ TEST_F(PartialScreenshotViewTest, BasicTouch) {
EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());
}
+// Partial screenshot session should not start when there is already another
+// overlay. See: crbug.com/341958
James Cook 2014/08/12 21:51:14 nit: I've started putting the "http://" part into
Jun Mukai 2014/08/12 22:51:03 Done.
+TEST_F(PartialScreenshotViewTest, DontStartOverOverlay) {
+ OverlayEventFilter* overlay_filter = Shell::GetInstance()->overlay_filter();
+ test::TestOverlayDelegate delegate;
+ overlay_filter->Activate(&delegate);
+
+ EXPECT_EQ(&delegate, overlay_filter->delegate_);
James Cook 2014/08/12 21:51:15 nit: Maybe move up a line?
Jun Mukai 2014/08/12 22:51:03 Done.
+
+ StartPartialScreenshot();
+ EXPECT_FALSE(view_);
+ EXPECT_EQ(&delegate, overlay_filter->delegate_);
+ overlay_filter->Deactivate(&delegate);
+
+ StartPartialScreenshot();
+ EXPECT_TRUE(view_);
+
+ // Someone else attempts to activate the overlay session, which should cancel
+ // the current partial screenshot session.
+ overlay_filter->Activate(&delegate);
+ RunAllPendingInMessageLoop();
+ EXPECT_EQ(&delegate, overlay_filter->delegate_);
+ EXPECT_FALSE(view_);
+}
James Cook 2014/08/12 21:51:15 Nice test.
Jun Mukai 2014/08/12 22:51:03 thanks :)
+
} // namespace ash
« ash/wm/overlay_event_filter_unittest.cc ('K') | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698