| Index: ash/wm/workspace/workspace_event_handler_unittest.cc
|
| diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
|
| index e72f1eef5bcde2bc442ed07df1987bd0d047d570..f97038504df03c7d1c5b0f57ee2e18cbc572b875 100644
|
| --- a/ash/wm/workspace/workspace_event_handler_unittest.cc
|
| +++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
|
| @@ -12,9 +12,11 @@
|
| #include "ash/wm/workspace_controller.h"
|
| #include "ash/wm/workspace_controller_test_helper.h"
|
| #include "ui/aura/client/aura_constants.h"
|
| +#include "ui/aura/root_window.h"
|
| #include "ui/aura/test/event_generator.h"
|
| #include "ui/aura/test/test_window_delegate.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/aura/window_property.h"
|
| #include "ui/base/hit_test.h"
|
| #include "ui/gfx/screen.h"
|
|
|
| @@ -46,6 +48,37 @@ class WorkspaceEventHandlerTest : public test::AshTestBase {
|
| DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTest);
|
| };
|
|
|
| +// Keeps track of the properties changed of a particular window.
|
| +class WindowPropertyObserver : public aura::WindowObserver {
|
| + public:
|
| + explicit WindowPropertyObserver(aura::Window* window)
|
| + : window_(window) {
|
| + window->AddObserver(this);
|
| + }
|
| +
|
| + virtual ~WindowPropertyObserver() {
|
| + window_->RemoveObserver(this);
|
| + }
|
| +
|
| + bool DidPropertyChange(const void* property) const {
|
| + return std::find(properties_changed_.begin(),
|
| + properties_changed_.end(),
|
| + property) != properties_changed_.end();
|
| + }
|
| +
|
| + private:
|
| + virtual void OnWindowPropertyChanged(aura::Window* window,
|
| + const void* key,
|
| + intptr_t old) OVERRIDE {
|
| + properties_changed_.push_back(key);
|
| + }
|
| +
|
| + aura::Window* window_;
|
| + std::vector<const void*> properties_changed_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver);
|
| +};
|
| +
|
| TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
|
| // Double clicking the vertical resize edge of a window should maximize it
|
| // vertically.
|
| @@ -219,8 +252,8 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
|
| window->SetProperty(aura::client::kCanMaximizeKey, true);
|
| wd.set_window_component(HTCAPTION);
|
| EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
|
| - aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
|
| - window.get());
|
| + aura::RootWindow* root = Shell::GetPrimaryRootWindow();
|
| + aura::test::EventGenerator generator(root, window.get());
|
| generator.DoubleClickLeftButton();
|
| EXPECT_NE("1,2 3x4", window->bounds().ToString());
|
|
|
| @@ -229,6 +262,21 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
|
|
|
| EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
|
| EXPECT_EQ("1,2 3x4", window->bounds().ToString());
|
| +
|
| + // Double-clicking the middle button shouldn't toggle the maximized state.
|
| + WindowPropertyObserver observer(window.get());
|
| + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, generator.current_location(),
|
| + generator.current_location(),
|
| + ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK);
|
| + root->AsRootWindowHostDelegate()->OnHostMouseEvent(&press);
|
| + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, generator.current_location(),
|
| + generator.current_location(),
|
| + ui::EF_IS_DOUBLE_CLICK);
|
| + root->AsRootWindowHostDelegate()->OnHostMouseEvent(&release);
|
| +
|
| + EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
|
| + EXPECT_EQ("1,2 3x4", window->bounds().ToString());
|
| + EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey));
|
| }
|
|
|
| TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) {
|
|
|