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

Side by Side Diff: views/controls/single_split_view_unittest.cc

Issue 6685069: Disambiguate OnMouseCaptureLost from OnMouseReleased, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, fix tests, cleanup, etc. Created 9 years, 9 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 | « views/controls/single_split_view.cc ('k') | views/controls/textfield/native_textfield_views.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/logging.h" 5 #include "base/logging.h"
6 #include "testing/gmock/include/gmock/gmock.h" 6 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "views/controls/single_split_view.h" 8 #include "views/controls/single_split_view.h"
9 9
10 using ::testing::_; 10 using ::testing::_;
11 using ::testing::Return; 11 using ::testing::Return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 } 127 }
128 128
129 TEST(SingleSplitViewTest, MouseDrag) { 129 TEST(SingleSplitViewTest, MouseDrag) {
130 MockObserver observer; 130 MockObserver observer;
131 SingleSplitView split( 131 SingleSplitView split(
132 new View(), new View(), SingleSplitView::VERTICAL_SPLIT, &observer); 132 new View(), new View(), SingleSplitView::VERTICAL_SPLIT, &observer);
133 133
134 ON_CALL(observer, SplitHandleMoved(_)) 134 ON_CALL(observer, SplitHandleMoved(_))
135 .WillByDefault(Return(true)); 135 .WillByDefault(Return(true));
136 // SplitHandleMoved is expected to be called once for every mouse move. 136 // SplitHandleMoved is called for two mouse moves and one mouse capture loss.
137 EXPECT_CALL(observer, SplitHandleMoved(_)) 137 EXPECT_CALL(observer, SplitHandleMoved(_))
138 .Times(2); 138 .Times(3);
139 139
140 split.SetBounds(0, 0, 10, 100); 140 split.SetBounds(0, 0, 10, 100);
141 const int kInitialDividerOffset = 33; 141 const int kInitialDividerOffset = 33;
142 const int kMouseOffset = 2; // Mouse offset in the divider. 142 const int kMouseOffset = 2; // Mouse offset in the divider.
143 const int kMouseMoveDelta = 7; 143 const int kMouseMoveDelta = 7;
144 split.set_divider_offset(kInitialDividerOffset); 144 split.set_divider_offset(kInitialDividerOffset);
145 split.Layout(); 145 split.Layout();
146 146
147 // Drag divider to the right, in 2 steps. 147 // Drag divider to the right, in 2 steps.
148 MouseEvent mouse_pressed( 148 MouseEvent mouse_pressed(
(...skipping 10 matching lines...) Expand all
159 MouseEvent mouse_dragged_2( 159 MouseEvent mouse_dragged_2(
160 ui::ET_MOUSE_DRAGGED, 6, 160 ui::ET_MOUSE_DRAGGED, 6,
161 kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0); 161 kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0);
162 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2)); 162 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2));
163 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, 163 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
164 split.divider_offset()); 164 split.divider_offset());
165 165
166 MouseEvent mouse_released( 166 MouseEvent mouse_released(
167 ui::ET_MOUSE_RELEASED, 7, 167 ui::ET_MOUSE_RELEASED, 7,
168 kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0); 168 kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0);
169 split.OnMouseReleased(mouse_released, false); 169 split.OnMouseReleased(mouse_released);
170 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, 170 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
171 split.divider_offset()); 171 split.divider_offset());
172
173 // Expect intial offset after a system/user gesture cancels the drag.
174 // This shouldn't occur after mouse release, but it's sufficient for testing.
175 split.OnMouseCaptureLost();
176 EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
172 } 177 }
173 178
174 } // namespace views 179 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/single_split_view.cc ('k') | views/controls/textfield/native_textfield_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698