OLD | NEW |
---|---|
(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 "chrome/browser/ui/views/browser_modal_dialog.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/memory/ptr_util.h" | |
10 #include "chrome/browser/ui/browser.h" | |
11 #include "testing/gmock/include/gmock/gmock.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 using ::testing::_; | |
15 using ::testing::Return; | |
16 | |
17 class MockBrowserModalDialog : public BrowserModalDialog { | |
18 public: | |
19 MOCK_METHOD1(ActivateModalDialog, void(Browser*)); | |
20 MOCK_METHOD0(IsShowing, bool()); | |
21 }; | |
22 | |
23 class BrowserModalDialogTest : public ::testing::Test { | |
24 public: | |
25 void SetUp() override { | |
26 dialog_list_ = BrowserModalDialogList::GetInstance(); | |
27 } | |
28 BrowserModalDialogList* dialog_list_; | |
29 }; | |
sky
2017/05/17 18:03:18
private: DISALLOW.
optional: Although that said th
zmin
2017/05/18 03:31:18
Done.
| |
30 | |
31 TEST_F(BrowserModalDialogTest, ShowDialog) { | |
32 ASSERT_FALSE(dialog_list_->IsShowing()); | |
33 MockBrowserModalDialog dialog; | |
34 EXPECT_CALL(dialog, IsShowing()).Times(2).WillRepeatedly(Return(true)); | |
35 EXPECT_CALL(dialog, ActivateModalDialog(_)).Times(1); | |
36 ASSERT_TRUE(dialog_list_->IsShowing()); | |
37 dialog_list_->ActivateModalDialog(nullptr); | |
38 } | |
39 | |
40 TEST_F(BrowserModalDialogTest, RemoveDialog) { | |
41 std::unique_ptr<MockBrowserModalDialog> dialog = | |
42 base::MakeUnique<MockBrowserModalDialog>(); | |
43 EXPECT_CALL(*dialog, IsShowing()).Times(1).WillRepeatedly(Return(true)); | |
44 ASSERT_TRUE(dialog_list_->IsShowing()); | |
45 dialog.reset(); | |
46 ASSERT_FALSE(dialog_list_->IsShowing()); | |
47 } | |
OLD | NEW |