Index: chrome/browser/ui/views/browser_modal_dialog_unittest.cc |
diff --git a/chrome/browser/ui/views/browser_modal_dialog_unittest.cc b/chrome/browser/ui/views/browser_modal_dialog_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4912e40619c3143a9b86359df9e875fc7d88932f |
--- /dev/null |
+++ b/chrome/browser/ui/views/browser_modal_dialog_unittest.cc |
@@ -0,0 +1,46 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <memory> |
+ |
+#include "base/memory/ptr_util.h" |
+#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.
|
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+using ::testing::_; |
+using ::testing::Return; |
+ |
+class MockBrowserModalDialog : public BrowserModalDialog { |
+ public: |
+ MOCK_METHOD0(ActivateModalDialog, void()); |
+ MOCK_METHOD0(IsShowing, bool()); |
+}; |
+ |
+class BrowserModalDialogTest : public ::testing::Test { |
+ public: |
+ void SetUp() override { |
+ dialog_list_ = BrowserModalDialogList::GetInstance(); |
+ } |
+ BrowserModalDialogList* dialog_list_; |
+}; |
+ |
+TEST_F(BrowserModalDialogTest, ShowDialog) { |
+ ASSERT_FALSE(dialog_list_->IsShowing()); |
+ MockBrowserModalDialog dialog; |
+ EXPECT_CALL(dialog, IsShowing()).Times(2).WillRepeatedly(Return(true)); |
+ EXPECT_CALL(dialog, ActivateModalDialog()).Times(1); |
+ ASSERT_TRUE(dialog_list_->IsShowing()); |
+ ASSERT_TRUE(dialog_list_->ActivateModalDialog()); |
+} |
+ |
+TEST_F(BrowserModalDialogTest, RemoveDialog) { |
+ std::unique_ptr<MockBrowserModalDialog> dialog = |
+ base::MakeUnique<MockBrowserModalDialog>(); |
+ EXPECT_CALL(*dialog, IsShowing()).Times(1).WillRepeatedly(Return(true)); |
+ ASSERT_TRUE(dialog_list_->IsShowing()); |
+ dialog.reset(); |
+ ASSERT_FALSE(dialog_list_->IsShowing()); |
+ ASSERT_FALSE(dialog_list_->ActivateModalDialog()); |
+} |