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

Unified Diff: ui/views/controls/single_split_view_unittest.cc

Issue 107363004: ui/views: Remove gmock dependency from views_unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/DEPS ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/single_split_view_unittest.cc
diff --git a/ui/views/controls/single_split_view_unittest.cc b/ui/views/controls/single_split_view_unittest.cc
index f82c1b5b090f30ae36e743f91f697923f7a87c9b..67022f8d0ef68a4da731055f65268ad846fcbf8b 100644
--- a/ui/views/controls/single_split_view_unittest.cc
+++ b/ui/views/controls/single_split_view_unittest.cc
@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/views/controls/single_split_view.h"
+
#include "base/logging.h"
-#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/views/controls/single_split_view.h"
#include "ui/views/controls/single_split_view_listener.h"
-using ::testing::_;
-using ::testing::Return;
-
namespace {
static void VerifySplitViewLayout(const views::SingleSplitView& split) {
@@ -44,9 +41,21 @@ static void VerifySplitViewLayout(const views::SingleSplitView& split) {
}
}
-class MockObserver : public views::SingleSplitViewListener {
+class SingleSplitViewListenerImpl : public views::SingleSplitViewListener {
public:
- MOCK_METHOD1(SplitHandleMoved, bool(views::SingleSplitView*));
+ SingleSplitViewListenerImpl() : count_(0) {}
+
+ virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE {
+ ++count_;
+ return false;
+ }
+
+ int count() const { return count_; }
+
+ private:
+ int count_;
+
+ DISALLOW_COPY_AND_ASSIGN(SingleSplitViewListenerImpl);
};
class MinimumSizedView: public views::View {
@@ -141,20 +150,14 @@ TEST(SingleSplitViewTest, Resize) {
}
TEST(SingleSplitViewTest, MouseDrag) {
- MockObserver observer;
const int kMinimumChildSize = 25;
MinimumSizedView *child0 =
new MinimumSizedView(gfx::Size(5, kMinimumChildSize));
MinimumSizedView *child1 =
new MinimumSizedView(gfx::Size(5, kMinimumChildSize));
+ SingleSplitViewListenerImpl listener;
SingleSplitView split(
- child0, child1, SingleSplitView::VERTICAL_SPLIT, &observer);
-
- ON_CALL(observer, SplitHandleMoved(_))
- .WillByDefault(Return(true));
- // SplitHandleMoved is called for two mouse moves and one mouse capture loss.
- EXPECT_CALL(observer, SplitHandleMoved(_))
- .Times(5);
+ child0, child1, SingleSplitView::VERTICAL_SPLIT, &listener);
const int kTotalSplitSize = 100;
split.SetBounds(0, 0, 10, kTotalSplitSize);
@@ -169,6 +172,7 @@ TEST(SingleSplitViewTest, MouseDrag) {
ui::ET_MOUSE_PRESSED, press_point, press_point, 0);
ASSERT_TRUE(split.OnMousePressed(mouse_pressed));
EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
+ EXPECT_EQ(0, listener.count());
// Drag divider to the bottom.
gfx::Point drag_1_point(
@@ -177,6 +181,7 @@ TEST(SingleSplitViewTest, MouseDrag) {
ui::ET_MOUSE_DRAGGED, drag_1_point, drag_1_point, 0);
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_1));
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta, split.divider_offset());
+ EXPECT_EQ(1, listener.count());
// Drag divider to the top, beyond first child minimum size.
gfx::Point drag_2_point(
@@ -184,8 +189,8 @@ TEST(SingleSplitViewTest, MouseDrag) {
ui::MouseEvent mouse_dragged_2(
ui::ET_MOUSE_DRAGGED, drag_2_point, drag_2_point, 0);
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2));
- EXPECT_EQ(kMinimumChildSize,
- split.divider_offset());
+ EXPECT_EQ(kMinimumChildSize, split.divider_offset());
+ EXPECT_EQ(2, listener.count());
// Drag divider to the bottom, beyond second child minimum size.
gfx::Point drag_3_point(
@@ -195,6 +200,7 @@ TEST(SingleSplitViewTest, MouseDrag) {
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_3));
EXPECT_EQ(kTotalSplitSize - kMinimumChildSize - split.GetDividerSize(),
split.divider_offset());
+ EXPECT_EQ(3, listener.count());
// Drag divider between childs' minimum sizes.
gfx::Point drag_4_point(
@@ -204,6 +210,7 @@ TEST(SingleSplitViewTest, MouseDrag) {
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_4));
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
split.divider_offset());
+ EXPECT_EQ(4, listener.count());
gfx::Point release_point(
7, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2);
@@ -217,6 +224,7 @@ TEST(SingleSplitViewTest, MouseDrag) {
// This shouldn't occur after mouse release, but it's sufficient for testing.
split.OnMouseCaptureLost();
EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
+ EXPECT_EQ(5, listener.count());
}
} // namespace views
« no previous file with comments | « ui/views/DEPS ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698