 Chromium Code Reviews
 Chromium Code Reviews Issue 2862653002:
  If force-sign-in policy is enabled,  popup warning dialog before window closing if auth token becom…  (Closed)
    
  
    Issue 2862653002:
  If force-sign-in policy is enabled,  popup warning dialog before window closing if auth token becom…  (Closed) 
  | 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..b6255a93542b91164c4e066782613a5c00a29d46 | 
| --- /dev/null | 
| +++ b/chrome/browser/ui/views/browser_modal_dialog_unittest.cc | 
| @@ -0,0 +1,47 @@ | 
| +// 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: | 
| + MOCK_METHOD1(ActivateModalDialog, void(Browser*)); | 
| + MOCK_METHOD0(IsShowing, bool()); | 
| +}; | 
| + | 
| +class BrowserModalDialogTest : public ::testing::Test { | 
| + public: | 
| + void SetUp() override { | 
| + dialog_list_ = BrowserModalDialogList::GetInstance(); | 
| + } | 
| + BrowserModalDialogList* dialog_list_; | 
| +}; | 
| 
sky
2017/05/17 18:03:18
private: DISALLOW.
optional: Although that said th
 
zmin
2017/05/18 03:31:18
Done.
 | 
| + | 
| +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()); | 
| + dialog_list_->ActivateModalDialog(nullptr); | 
| +} | 
| + | 
| +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()); | 
| +} |