| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/chrome_cleaner_dialog_win.h" | 5 #include "chrome/browser/ui/views/chrome_cleaner_dialog_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_
win.h" | 11 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_
win.h" |
| 12 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_dialog_cont
roller_win.h" | 12 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_dialog_cont
roller_win.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 15 #include "chrome/browser/ui/test/test_browser_dialog.h" | 15 #include "chrome/browser/ui/test/test_browser_dialog.h" |
| 16 #include "content/public/test/browser_test.h" | 16 #include "content/public/test/browser_test.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using ::testing::_; | 20 using ::testing::_; |
| 21 using ::testing::NiceMock; | 21 using ::testing::NiceMock; |
| 22 using ::testing::Return; | 22 using ::testing::Return; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class MockChromeCleanerDialogController | 26 class MockChromeCleanerDialogController |
| 27 : public safe_browsing::ChromeCleanerDialogController { | 27 : public safe_browsing::ChromeCleanerDialogController { |
| 28 public: | 28 public: |
| 29 MOCK_METHOD0(DialogShown, void()); | 29 MOCK_METHOD0(DialogShown, void()); |
| 30 MOCK_METHOD0(Accept, void()); | 30 MOCK_METHOD1(Accept, void(bool)); |
| 31 MOCK_METHOD0(Cancel, void()); | 31 MOCK_METHOD0(Cancel, void()); |
| 32 MOCK_METHOD0(Close, void()); | 32 MOCK_METHOD0(Close, void()); |
| 33 MOCK_METHOD0(DetailsButtonClicked, void()); | 33 MOCK_METHOD1(DetailsButtonClicked, void(bool)); |
| 34 MOCK_METHOD1(SetLogsEnabled, void(bool)); |
| 35 MOCK_METHOD0(LogsEnabled, bool()); |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 class ChromeCleanerDialogTest : public DialogBrowserTest { | 38 class ChromeCleanerDialogTest : public DialogBrowserTest { |
| 37 public: | 39 public: |
| 38 ChromeCleanerDialogTest() | 40 ChromeCleanerDialogTest() |
| 39 : mock_dialog_controller_( | 41 : mock_dialog_controller_( |
| 40 base::MakeUnique<NiceMock<MockChromeCleanerDialogController>>()) {} | 42 base::MakeUnique<NiceMock<MockChromeCleanerDialogController>>()) { |
| 43 ON_CALL(*mock_dialog_controller_, LogsEnabled()) |
| 44 .WillByDefault(Return(true)); |
| 45 } |
| 41 | 46 |
| 42 void ShowDialog(const std::string& name) override { | 47 void ShowDialog(const std::string& name) override { |
| 43 chrome::ShowChromeCleanerPrompt(browser(), mock_dialog_controller_.get()); | 48 chrome::ShowChromeCleanerPrompt(browser(), mock_dialog_controller_.get()); |
| 44 } | 49 } |
| 45 | 50 |
| 46 protected: | 51 protected: |
| 47 // Since the DialogBrowserTest can be run interactively, we use NiceMock here | 52 // Since the DialogBrowserTest can be run interactively, we use NiceMock here |
| 48 // to suppress warnings about uninteresting calls. | 53 // to suppress warnings about uninteresting calls. |
| 49 std::unique_ptr<NiceMock<MockChromeCleanerDialogController>> | 54 std::unique_ptr<NiceMock<MockChromeCleanerDialogController>> |
| 50 mock_dialog_controller_; | 55 mock_dialog_controller_; |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerDialogTest); | 58 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerDialogTest); |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 IN_PROC_BROWSER_TEST_F(ChromeCleanerDialogTest, InvokeDialog_default) { | 61 IN_PROC_BROWSER_TEST_F(ChromeCleanerDialogTest, InvokeDialog_default) { |
| 57 RunDialog(); | 62 RunDialog(); |
| 58 } | 63 } |
| 59 | 64 |
| 60 } // namespace | 65 } // namespace |
| OLD | NEW |