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

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

Issue 7349021: Convert some more view methods to the ui/views style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 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;
12 12
13 namespace { 13 namespace {
14 14
15 static void VerifySplitViewLayout(const views::SingleSplitView& split) { 15 static void VerifySplitViewLayout(const views::SingleSplitView& split) {
16 ASSERT_EQ(2, split.child_count()); 16 ASSERT_EQ(2, split.child_count());
17 17
18 const views::View* leading = split.GetChildViewAt(0); 18 const views::View* leading = split.child_at(0);
19 const views::View* trailing = split.GetChildViewAt(1); 19 const views::View* trailing = split.child_at(1);
20 20
21 if (split.bounds().IsEmpty()) { 21 if (split.bounds().IsEmpty()) {
22 EXPECT_TRUE(leading->bounds().IsEmpty()); 22 EXPECT_TRUE(leading->bounds().IsEmpty());
23 EXPECT_TRUE(trailing->bounds().IsEmpty()); 23 EXPECT_TRUE(trailing->bounds().IsEmpty());
24 return; 24 return;
25 } 25 }
26 26
27 EXPECT_FALSE(leading->bounds().IsEmpty()); 27 EXPECT_FALSE(leading->bounds().IsEmpty());
28 EXPECT_FALSE(trailing->bounds().IsEmpty()); 28 EXPECT_FALSE(trailing->bounds().IsEmpty());
29 EXPECT_FALSE(leading->bounds().Intersects(trailing->bounds())); 29 EXPECT_FALSE(leading->bounds().Intersects(trailing->bounds()));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } else { 106 } else {
107 split.SetBounds(0, 0, test_cases[i].secondary_axis_size, 107 split.SetBounds(0, 0, test_cases[i].secondary_axis_size,
108 test_cases[i].primary_axis_size); 108 test_cases[i].primary_axis_size);
109 } 109 }
110 110
111 EXPECT_EQ(test_cases[i].divider_offset, split.divider_offset()); 111 EXPECT_EQ(test_cases[i].divider_offset, split.divider_offset());
112 VerifySplitViewLayout(split); 112 VerifySplitViewLayout(split);
113 } 113 }
114 114
115 // Special cases, one of the child views is hidden. 115 // Special cases, one of the child views is hidden.
116 split.GetChildViewAt(0)->SetVisible(false); 116 split.child_at(0)->SetVisible(false);
117 split.Layout(); 117 split.Layout();
118 118
119 EXPECT_EQ(split.size(), split.GetChildViewAt(1)->size()); 119 EXPECT_EQ(split.size(), split.child_at(1)->size());
120 120
121 split.GetChildViewAt(0)->SetVisible(true); 121 split.child_at(0)->SetVisible(true);
122 split.GetChildViewAt(1)->SetVisible(false); 122 split.child_at(1)->SetVisible(false);
123 split.Layout(); 123 split.Layout();
124 124
125 EXPECT_EQ(split.size(), split.GetChildViewAt(0)->size()); 125 EXPECT_EQ(split.size(), split.child_at(0)->size());
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));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, 170 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
171 split.divider_offset()); 171 split.divider_offset());
172 172
173 // Expect intial offset after a system/user gesture cancels the drag. 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. 174 // This shouldn't occur after mouse release, but it's sufficient for testing.
175 split.OnMouseCaptureLost(); 175 split.OnMouseCaptureLost();
176 EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); 176 EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
177 } 177 }
178 178
179 } // namespace views 179 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/single_split_view.cc ('k') | views/controls/tabbed_pane/native_tabbed_pane_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698