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

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: win fix 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
« no previous file with comments | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..26e27e3ca8bc192d76b3d83963e22bc5b76e6b8a 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,28 @@ 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: http://crbug.com/341958
+TEST_F(PartialScreenshotViewTest, DontStartOverOverlay) {
+ OverlayEventFilter* overlay_filter = Shell::GetInstance()->overlay_filter();
+ test::TestOverlayDelegate delegate;
+ overlay_filter->Activate(&delegate);
+ EXPECT_EQ(&delegate, overlay_filter->delegate_);
+
+ StartPartialScreenshot();
+ EXPECT_TRUE(view_ == NULL);
+ EXPECT_EQ(&delegate, overlay_filter->delegate_);
+ overlay_filter->Deactivate(&delegate);
+
+ StartPartialScreenshot();
+ EXPECT_TRUE(view_ != NULL);
+
+ // 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_TRUE(view_ == NULL);
+}
+
} // namespace ash
« 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