| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // the widget is active. We need this to ensure that users of the widget | 652 // the widget is active. We need this to ensure that users of the widget |
| 653 // class activate the widget only when the underlying window becomes really | 653 // class activate the widget only when the underlying window becomes really |
| 654 // active. Previously we would activate the widget in the WM_NCACTIVATE | 654 // active. Previously we would activate the widget in the WM_NCACTIVATE |
| 655 // message which is incorrect because APIs like FlashWindowEx flash the | 655 // message which is incorrect because APIs like FlashWindowEx flash the |
| 656 // window caption by sending fake WM_NCACTIVATE messages. | 656 // window caption by sending fake WM_NCACTIVATE messages. |
| 657 class WidgetActivationTest : public Widget { | 657 class WidgetActivationTest : public Widget { |
| 658 public: | 658 public: |
| 659 WidgetActivationTest() | 659 WidgetActivationTest() |
| 660 : active_(false) {} | 660 : active_(false) {} |
| 661 | 661 |
| 662 virtual ~WidgetActivationTest() {} | 662 ~WidgetActivationTest() override {} |
| 663 | 663 |
| 664 virtual void OnNativeWidgetActivationChanged(bool active) override { | 664 void OnNativeWidgetActivationChanged(bool active) override { |
| 665 active_ = active; | 665 active_ = active; |
| 666 } | 666 } |
| 667 | 667 |
| 668 bool active() const { return active_; } | 668 bool active() const { return active_; } |
| 669 | 669 |
| 670 private: | 670 private: |
| 671 bool active_; | 671 bool active_; |
| 672 | 672 |
| 673 DISALLOW_COPY_AND_ASSIGN(WidgetActivationTest); | 673 DISALLOW_COPY_AND_ASSIGN(WidgetActivationTest); |
| 674 }; | 674 }; |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 | 1338 |
| 1339 #if defined(OS_WIN) | 1339 #if defined(OS_WIN) |
| 1340 namespace { | 1340 namespace { |
| 1341 | 1341 |
| 1342 // Used to verify OnMouseEvent() has been invoked. | 1342 // Used to verify OnMouseEvent() has been invoked. |
| 1343 class MouseEventTrackingWidget : public Widget { | 1343 class MouseEventTrackingWidget : public Widget { |
| 1344 public: | 1344 public: |
| 1345 MouseEventTrackingWidget() : got_mouse_event_(false) {} | 1345 MouseEventTrackingWidget() : got_mouse_event_(false) {} |
| 1346 virtual ~MouseEventTrackingWidget() {} | 1346 ~MouseEventTrackingWidget() override {} |
| 1347 | 1347 |
| 1348 bool GetAndClearGotMouseEvent() { | 1348 bool GetAndClearGotMouseEvent() { |
| 1349 bool value = got_mouse_event_; | 1349 bool value = got_mouse_event_; |
| 1350 got_mouse_event_ = false; | 1350 got_mouse_event_ = false; |
| 1351 return value; | 1351 return value; |
| 1352 } | 1352 } |
| 1353 | 1353 |
| 1354 // Widget: | 1354 // Widget: |
| 1355 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 1355 void OnMouseEvent(ui::MouseEvent* event) override { |
| 1356 got_mouse_event_ = true; | 1356 got_mouse_event_ = true; |
| 1357 Widget::OnMouseEvent(event); | 1357 Widget::OnMouseEvent(event); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 private: | 1360 private: |
| 1361 bool got_mouse_event_; | 1361 bool got_mouse_event_; |
| 1362 | 1362 |
| 1363 DISALLOW_COPY_AND_ASSIGN(MouseEventTrackingWidget); | 1363 DISALLOW_COPY_AND_ASSIGN(MouseEventTrackingWidget); |
| 1364 }; | 1364 }; |
| 1365 | 1365 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 1399 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
| 1400 GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 1400 GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
| 1401 ASSERT_FALSE(details.dispatcher_destroyed); | 1401 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1402 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 1402 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
| 1403 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 1403 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
| 1404 } | 1404 } |
| 1405 #endif // defined(OS_WIN) | 1405 #endif // defined(OS_WIN) |
| 1406 | 1406 |
| 1407 } // namespace test | 1407 } // namespace test |
| 1408 } // namespace views | 1408 } // namespace views |
| OLD | NEW |