| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 typedef NativeWidgetAura NativeWidgetPlatform; | 29 typedef NativeWidgetAura NativeWidgetPlatform; |
| 30 #elif defined(OS_WIN) | 30 #elif defined(OS_WIN) |
| 31 typedef NativeWidgetWin NativeWidgetPlatform; | 31 typedef NativeWidgetWin NativeWidgetPlatform; |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 // A widget that assumes mouse capture always works. It won't on Aura in | 34 // A widget that assumes mouse capture always works. It won't on Aura in |
| 35 // testing, so we mock it. | 35 // testing, so we mock it. |
| 36 #if defined(USE_AURA) | 36 #if defined(USE_AURA) |
| 37 class NativeWidgetCapture : public NativeWidgetPlatform { | 37 class NativeWidgetCapture : public NativeWidgetPlatform { |
| 38 public: | 38 public: |
| 39 NativeWidgetCapture(internal::NativeWidgetDelegate* delegate) | 39 explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate) |
| 40 : NativeWidgetPlatform(delegate), | 40 : NativeWidgetPlatform(delegate), |
| 41 mouse_capture_(false) {} | 41 mouse_capture_(false) {} |
| 42 virtual ~NativeWidgetCapture() {} | 42 virtual ~NativeWidgetCapture() {} |
| 43 | 43 |
| 44 virtual void SetCapture(unsigned int flags) OVERRIDE { | 44 virtual void SetCapture(unsigned int flags) OVERRIDE { |
| 45 if (!(flags & ui::CW_LOCK_MOUSE)) | 45 if (!(flags & ui::CW_LOCK_MOUSE)) |
| 46 return; | 46 return; |
| 47 mouse_capture_ = true; | 47 mouse_capture_ = true; |
| 48 } | 48 } |
| 49 virtual void ReleaseCapture() OVERRIDE { | 49 virtual void ReleaseCapture() OVERRIDE { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 private: | 398 private: |
| 399 OwnershipTestState* state_; | 399 OwnershipTestState* state_; |
| 400 | 400 |
| 401 DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidgetPlatform); | 401 DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidgetPlatform); |
| 402 }; | 402 }; |
| 403 | 403 |
| 404 // A Widget subclass that updates a bag of state when it is destroyed. | 404 // A Widget subclass that updates a bag of state when it is destroyed. |
| 405 class OwnershipTestWidget : public Widget { | 405 class OwnershipTestWidget : public Widget { |
| 406 public: | 406 public: |
| 407 OwnershipTestWidget(OwnershipTestState* state) : state_(state) {} | 407 explicit OwnershipTestWidget(OwnershipTestState* state) : state_(state) {} |
| 408 virtual ~OwnershipTestWidget() { | 408 virtual ~OwnershipTestWidget() { |
| 409 state_->widget_deleted = true; | 409 state_->widget_deleted = true; |
| 410 } | 410 } |
| 411 | 411 |
| 412 private: | 412 private: |
| 413 OwnershipTestState* state_; | 413 OwnershipTestState* state_; |
| 414 | 414 |
| 415 DISALLOW_COPY_AND_ASSIGN(OwnershipTestWidget); | 415 DISALLOW_COPY_AND_ASSIGN(OwnershipTestWidget); |
| 416 }; | 416 }; |
| 417 | 417 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // And it stays maximized after getting out of full screen. | 819 // And it stays maximized after getting out of full screen. |
| 820 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel)); | 820 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel)); |
| 821 | 821 |
| 822 // Clean up. | 822 // Clean up. |
| 823 toplevel->Close(); | 823 toplevel->Close(); |
| 824 RunPendingMessages(); | 824 RunPendingMessages(); |
| 825 } | 825 } |
| 826 | 826 |
| 827 } // namespace | 827 } // namespace |
| 828 } // namespace views | 828 } // namespace views |
| OLD | NEW |