Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: chrome/browser/ui/views/button_dropdown_test.cc

Issue 10832184: Fixed memory leak. Untangled confusing code with menu initialization and ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/test/base/ui_test_utils.h" 7 #include "chrome/test/base/ui_test_utils.h"
8 #include "chrome/test/base/view_event_test_base.h" 8 #include "chrome/test/base/view_event_test_base.h"
9 #include "ui/base/models/simple_menu_model.h" 9 #include "ui/base/models/simple_menu_model.h"
10 #include "ui/ui_controls/ui_controls.h" 10 #include "ui/ui_controls/ui_controls.h"
11 #include "ui/views/controls/button/button_dropdown.h" 11 #include "ui/views/controls/button/button_dropdown.h"
12 12
13 class ButtonDropDownDragTest : public ViewEventTestBase, 13 class ButtonDropDownDragTest : public ViewEventTestBase,
14 ui::SimpleMenuModel::Delegate { 14 ui::SimpleMenuModel::Delegate {
15 public: 15 public:
16 ButtonDropDownDragTest() 16 ButtonDropDownDragTest()
17 : button_(NULL), 17 : button_(NULL),
18 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)),
19 menu_shown_(false), 18 menu_shown_(false),
20 menu_closed_(false) { 19 menu_closed_(false) {
21 } 20 }
22 21
23 virtual ~ButtonDropDownDragTest() { 22 virtual ~ButtonDropDownDragTest() {
24 } 23 }
25 24
26 // ViewEventTestBase implementation. 25 // ViewEventTestBase implementation.
27 virtual void SetUp() OVERRIDE { 26 virtual void SetUp() OVERRIDE {
28 button_ = new views::ButtonDropDown(NULL, &menu_model_); 27 button_ = new views::ButtonDropDown(NULL, new ui::SimpleMenuModel(this));
29 28
30 ViewEventTestBase::SetUp(); 29 ViewEventTestBase::SetUp();
31 } 30 }
32 31
33 virtual void TearDown() OVERRIDE { 32 virtual void TearDown() OVERRIDE {
34 ViewEventTestBase::TearDown(); 33 ViewEventTestBase::TearDown();
35 } 34 }
36 35
37 virtual views::View* CreateContentsView() OVERRIDE { 36 virtual views::View* CreateContentsView() OVERRIDE {
38 return button_; 37 return button_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CreateEventTask(this, &ButtonDropDownDragTest::Step5)); 117 CreateEventTask(this, &ButtonDropDownDragTest::Step5));
119 } 118 }
120 119
121 void Step5() { 120 void Step5() {
122 ASSERT_TRUE(menu_closed_); 121 ASSERT_TRUE(menu_closed_);
123 Done(); 122 Done();
124 } 123 }
125 124
126 private: 125 private:
127 views::ButtonDropDown* button_; 126 views::ButtonDropDown* button_;
128 ui::SimpleMenuModel menu_model_;
129 bool menu_shown_; 127 bool menu_shown_;
130 bool menu_closed_; 128 bool menu_closed_;
131 }; 129 };
132 130
133 #if defined(OS_WIN) 131 #if defined(OS_WIN)
134 #define MAYBE_DragActivation DISABLED_DragActivation 132 #define MAYBE_DragActivation DISABLED_DragActivation
135 #else 133 #else
136 #define MAYBE_DragActivation DragActivation 134 #define MAYBE_DragActivation DragActivation
137 #endif 135 #endif
138 VIEW_TEST(ButtonDropDownDragTest, MAYBE_DragActivation) 136 VIEW_TEST(ButtonDropDownDragTest, MAYBE_DragActivation)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698