| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/workspace/workspace_event_handler.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 | 31 |
| 32 class WorkspaceEventHandlerTest : public test::AshTestBase { | 32 class WorkspaceEventHandlerTest : public test::AshTestBase { |
| 33 public: | 33 public: |
| 34 WorkspaceEventHandlerTest() {} | 34 WorkspaceEventHandlerTest() {} |
| 35 virtual ~WorkspaceEventHandlerTest() {} | 35 ~WorkspaceEventHandlerTest() override {} |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 aura::Window* CreateTestWindow(aura::WindowDelegate* delegate, | 38 aura::Window* CreateTestWindow(aura::WindowDelegate* delegate, |
| 39 const gfx::Rect& bounds) { | 39 const gfx::Rect& bounds) { |
| 40 aura::Window* window = new aura::Window(delegate); | 40 aura::Window* window = new aura::Window(delegate); |
| 41 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 41 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 42 window->Init(aura::WINDOW_LAYER_TEXTURED); | 42 window->Init(aura::WINDOW_LAYER_TEXTURED); |
| 43 ParentWindowInPrimaryRootWindow(window); | 43 ParentWindowInPrimaryRootWindow(window); |
| 44 window->SetBounds(bounds); | 44 window->SetBounds(bounds); |
| 45 window->Show(); | 45 window->Show(); |
| 46 return window; | 46 return window; |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTest); | 50 DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTest); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Keeps track of the properties changed of a particular window. | 53 // Keeps track of the properties changed of a particular window. |
| 54 class WindowPropertyObserver : public aura::WindowObserver { | 54 class WindowPropertyObserver : public aura::WindowObserver { |
| 55 public: | 55 public: |
| 56 explicit WindowPropertyObserver(aura::Window* window) | 56 explicit WindowPropertyObserver(aura::Window* window) |
| 57 : window_(window) { | 57 : window_(window) { |
| 58 window->AddObserver(this); | 58 window->AddObserver(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual ~WindowPropertyObserver() { | 61 ~WindowPropertyObserver() override { window_->RemoveObserver(this); } |
| 62 window_->RemoveObserver(this); | |
| 63 } | |
| 64 | 62 |
| 65 bool DidPropertyChange(const void* property) const { | 63 bool DidPropertyChange(const void* property) const { |
| 66 return std::find(properties_changed_.begin(), | 64 return std::find(properties_changed_.begin(), |
| 67 properties_changed_.end(), | 65 properties_changed_.end(), |
| 68 property) != properties_changed_.end(); | 66 property) != properties_changed_.end(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 virtual void OnWindowPropertyChanged(aura::Window* window, | 70 void OnWindowPropertyChanged(aura::Window* window, |
| 73 const void* key, | 71 const void* key, |
| 74 intptr_t old) override { | 72 intptr_t old) override { |
| 75 properties_changed_.push_back(key); | 73 properties_changed_.push_back(key); |
| 76 } | 74 } |
| 77 | 75 |
| 78 aura::Window* window_; | 76 aura::Window* window_; |
| 79 std::vector<const void*> properties_changed_; | 77 std::vector<const void*> properties_changed_; |
| 80 | 78 |
| 81 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver); | 79 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver); |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { | 82 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 // Second click will go to the header | 540 // Second click will go to the header |
| 543 delegate.set_window_component(HTCAPTION); | 541 delegate.set_window_component(HTCAPTION); |
| 544 generator.PressRightButton(); | 542 generator.PressRightButton(); |
| 545 generator.ReleaseRightButton(); | 543 generator.ReleaseRightButton(); |
| 546 EXPECT_FALSE(window_state->IsMaximized()); | 544 EXPECT_FALSE(window_state->IsMaximized()); |
| 547 generator.DoubleClickLeftButton(); | 545 generator.DoubleClickLeftButton(); |
| 548 EXPECT_FALSE(window_state->IsMaximized()); | 546 EXPECT_FALSE(window_state->IsMaximized()); |
| 549 } | 547 } |
| 550 | 548 |
| 551 } // namespace ash | 549 } // namespace ash |
| OLD | NEW |