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 "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/events/event_utils.h" | 10 #include "ui/base/events/event_utils.h" |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 EXPECT_TRUE(delegate->on_before_init_called()); | 1739 EXPECT_TRUE(delegate->on_before_init_called()); |
1740 EXPECT_TRUE(delegate->is_top_level()); | 1740 EXPECT_TRUE(delegate->is_top_level()); |
1741 } | 1741 } |
1742 | 1742 |
1743 // A scumbag View that deletes its owning widget OnMousePressed. | 1743 // A scumbag View that deletes its owning widget OnMousePressed. |
1744 class WidgetDeleterView : public View { | 1744 class WidgetDeleterView : public View { |
1745 public: | 1745 public: |
1746 WidgetDeleterView() : View() {} | 1746 WidgetDeleterView() : View() {} |
1747 | 1747 |
1748 // Overridden from View. | 1748 // Overridden from View. |
1749 bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 1749 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { |
1750 delete GetWidget(); | 1750 delete GetWidget(); |
1751 return true; | 1751 return true; |
1752 } | 1752 } |
1753 | 1753 |
1754 private: | 1754 private: |
1755 DISALLOW_COPY_AND_ASSIGN(WidgetDeleterView); | 1755 DISALLOW_COPY_AND_ASSIGN(WidgetDeleterView); |
1756 }; | 1756 }; |
1757 | 1757 |
1758 TEST_F(WidgetTest, TestWidgetDeletedInOnMousePressed) { | 1758 TEST_F(WidgetTest, TestWidgetDeletedInOnMousePressed) { |
1759 Widget* widget = new Widget; | 1759 Widget* widget = new Widget; |
(...skipping 10 matching lines...) Expand all Loading... |
1770 gfx::Point click_location(45, 15); | 1770 gfx::Point click_location(45, 15); |
1771 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location, | 1771 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location, |
1772 ui::EF_LEFT_MOUSE_BUTTON); | 1772 ui::EF_LEFT_MOUSE_BUTTON); |
1773 widget->OnMouseEvent(&press); | 1773 widget->OnMouseEvent(&press); |
1774 | 1774 |
1775 // Yay we did not crash! | 1775 // Yay we did not crash! |
1776 } | 1776 } |
1777 | 1777 |
1778 } // namespace | 1778 } // namespace |
1779 } // namespace views | 1779 } // namespace views |
OLD | NEW |