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

Unified 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: nit Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1f3387d676f71acfcfa4f62b2b486bff92d59d58
--- /dev/null
+++ b/chrome/browser/ui/views/browser_modal_dialog_unittest.cc
@@ -0,0 +1,55 @@
+// 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 "chrome/browser/ui/views/browser_modal_dialog.h"
+
+#include <memory>
+
+#include "base/memory/ptr_util.h"
+#include "chrome/browser/ui/browser.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+using ::testing::Return;
+
+class MockBrowserModalDialog : public BrowserModalDialog {
+ public:
+ MockBrowserModalDialog() {
+ BrowserModalDialogList::GetInstance()->AddDialog(this);
+ }
+ ~MockBrowserModalDialog() override {
+ BrowserModalDialogList::GetInstance()->RemoveDialog(this);
+ }
+ MOCK_METHOD1(ActivateModalDialog, void(Browser*));
+ MOCK_METHOD0(IsShowing, bool());
+};
+
+class BrowserModalDialogTest : public ::testing::Test {
+ public:
+ BrowserModalDialogTest() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserModalDialogTest);
+};
+
+TEST_F(BrowserModalDialogTest, ShowDialog) {
+ BrowserModalDialogList* dialog_list = BrowserModalDialogList::GetInstance();
+ 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());
+ dialog_list->ActivateModalDialog(nullptr);
+}
+
+TEST_F(BrowserModalDialogTest, RemoveDialog) {
+ BrowserModalDialogList* dialog_list = BrowserModalDialogList::GetInstance();
+ 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());
+}
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698