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

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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Fix unit tests to use a ViewsDelegate to guard against crashes Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/views/global_error_bubble_view.h" 5 #include "chrome/browser/ui/views/global_error_bubble_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/ui/global_error/global_error.h" 10 #include "chrome/browser/ui/global_error/global_error.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gfx/codec/png_codec.h" 13 #include "ui/gfx/codec/png_codec.h"
14 #include "ui/gfx/image/image.h" 14 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/image/image_png_rep.h" 15 #include "ui/gfx/image/image_png_rep.h"
16 #include "ui/gfx/image/image_unittest_util.h" 16 #include "ui/gfx/image/image_unittest_util.h"
17 #include "ui/views/controls/button/button.h" 17 #include "ui/views/controls/button/button.h"
18 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/test/test_views_delegate.h"
19 20
20 using ::testing::_; 21 using ::testing::_;
21 using ::testing::Return; 22 using ::testing::Return;
22 using ::testing::StrictMock; 23 using ::testing::StrictMock;
23 24
24 namespace views { 25 namespace views {
25 class FakeButtonListener : public views::ButtonListener { 26 class FakeButtonListener : public views::ButtonListener {
26 public: 27 public:
27 FakeButtonListener() {} 28 FakeButtonListener() {}
28 ~FakeButtonListener() override; 29 ~FakeButtonListener() override;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 DISALLOW_COPY_AND_ASSIGN(MockGlobalErrorWithStandardBubble); 70 DISALLOW_COPY_AND_ASSIGN(MockGlobalErrorWithStandardBubble);
70 }; 71 };
71 72
72 MockGlobalErrorWithStandardBubble::~MockGlobalErrorWithStandardBubble() {} 73 MockGlobalErrorWithStandardBubble::~MockGlobalErrorWithStandardBubble() {}
73 74
74 } // namespace 75 } // namespace
75 76
76 class GlobalErrorBubbleViewTest : public testing::Test { 77 class GlobalErrorBubbleViewTest : public testing::Test {
77 public: 78 public:
78 GlobalErrorBubbleViewTest() 79 GlobalErrorBubbleViewTest()
79 : mock_global_error_with_standard_bubble_( 80 : views_delegate_(base::MakeUnique<TestViewsDelegate>()),
81 mock_global_error_with_standard_bubble_(
80 base::MakeUnique<StrictMock<MockGlobalErrorWithStandardBubble>>()), 82 base::MakeUnique<StrictMock<MockGlobalErrorWithStandardBubble>>()),
81 button_(&mock_button_listener_, base::string16()), 83 button_(&mock_button_listener_, base::string16()),
82 view_(base::MakeUnique<GlobalErrorBubbleView>( 84 view_(base::MakeUnique<GlobalErrorBubbleView>(
83 &arg_view_, 85 &arg_view_,
84 anchor_point_, 86 anchor_point_,
85 arrow_, 87 arrow_,
86 nullptr, 88 nullptr,
87 mock_global_error_with_standard_bubble_->AsWeakPtr())) {} 89 mock_global_error_with_standard_bubble_->AsWeakPtr())) {}
88 90
89 protected: 91 protected:
92 std::unique_ptr<TestViewsDelegate> views_delegate_;
90 std::unique_ptr<StrictMock<MockGlobalErrorWithStandardBubble>> 93 std::unique_ptr<StrictMock<MockGlobalErrorWithStandardBubble>>
91 mock_global_error_with_standard_bubble_; 94 mock_global_error_with_standard_bubble_;
92 views::View arg_view_; 95 views::View arg_view_;
93 const gfx::Point anchor_point_; 96 const gfx::Point anchor_point_;
94 views::BubbleBorder::Arrow arrow_; 97 views::BubbleBorder::Arrow arrow_;
95 FakeButtonListener mock_button_listener_; 98 FakeButtonListener mock_button_listener_;
96 views::LabelButton button_; 99 views::LabelButton button_;
97 std::unique_ptr<GlobalErrorBubbleView> view_; 100 std::unique_ptr<GlobalErrorBubbleView> view_;
98 101
99 private: 102 private:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 view_->GetDialogButtonLabel(ui::DIALOG_BUTTON_OK)); 166 view_->GetDialogButtonLabel(ui::DIALOG_BUTTON_OK));
164 EXPECT_EQ(base::string16(), 167 EXPECT_EQ(base::string16(),
165 view_->GetDialogButtonLabel(ui::DIALOG_BUTTON_CANCEL)); 168 view_->GetDialogButtonLabel(ui::DIALOG_BUTTON_CANCEL));
166 EXPECT_EQ(ui::DIALOG_BUTTON_NONE, view_->GetDialogButtons()); 169 EXPECT_EQ(ui::DIALOG_BUTTON_NONE, view_->GetDialogButtons());
167 170
168 view_->Cancel(); 171 view_->Cancel();
169 view_->Accept(); 172 view_->Accept();
170 } 173 }
171 174
172 } // namespace views 175 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698