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

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

Issue 2862653002: If force-sign-in policy is enabled, popup warning dialog before window closing if auth token becom… (Closed)
Patch Set: refactor Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <memory>
6
7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/ui/views/browser_modal_dialog.h"
sky 2017/05/16 12:40:33 this should be your first include, then newline, t
zmin 2017/05/16 22:22:02 Done.
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using ::testing::_;
13 using ::testing::Return;
14
15 class MockBrowserModalDialog : public BrowserModalDialog {
16 public:
17 MOCK_METHOD0(ActivateModalDialog, void());
18 MOCK_METHOD0(IsShowing, bool());
19 };
20
21 class BrowserModalDialogTest : public ::testing::Test {
22 public:
23 void SetUp() override {
24 dialog_list_ = BrowserModalDialogList::GetInstance();
25 }
26 BrowserModalDialogList* dialog_list_;
27 };
28
29 TEST_F(BrowserModalDialogTest, ShowDialog) {
30 ASSERT_FALSE(dialog_list_->IsShowing());
31 MockBrowserModalDialog dialog;
32 EXPECT_CALL(dialog, IsShowing()).Times(2).WillRepeatedly(Return(true));
33 EXPECT_CALL(dialog, ActivateModalDialog()).Times(1);
34 ASSERT_TRUE(dialog_list_->IsShowing());
35 ASSERT_TRUE(dialog_list_->ActivateModalDialog());
36 }
37
38 TEST_F(BrowserModalDialogTest, RemoveDialog) {
39 std::unique_ptr<MockBrowserModalDialog> dialog =
40 base::MakeUnique<MockBrowserModalDialog>();
41 EXPECT_CALL(*dialog, IsShowing()).Times(1).WillRepeatedly(Return(true));
42 ASSERT_TRUE(dialog_list_->IsShowing());
43 dialog.reset();
44 ASSERT_FALSE(dialog_list_->IsShowing());
45 ASSERT_FALSE(dialog_list_->ActivateModalDialog());
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698