| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugins/plugin_installer.h" | 5 #include "chrome/browser/plugins/plugin_installer.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/plugins/plugin_installer_observer.h" | 9 #include "chrome/browser/plugins/plugin_installer_observer.h" |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 11 #include "content/public/browser/download_url_parameters.h" | 11 #include "content/public/browser/download_url_parameters.h" |
| 12 #include "content/public/test/mock_download_item.h" | 12 #include "content/public/test/mock_download_item.h" |
| 13 #include "content/public/test/mock_download_manager.h" | 13 #include "content/public/test/mock_download_manager.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using ::testing::_; | 17 using ::testing::_; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class PluginInstallerTest : public ChromeRenderViewHostTestHarness { | 21 class PluginInstallerTest : public ChromeRenderViewHostTestHarness { |
| 22 public: | 22 public: |
| 23 PluginInstallerTest(); | 23 PluginInstallerTest(); |
| 24 virtual void SetUp() OVERRIDE; | 24 virtual void SetUp() override; |
| 25 virtual void TearDown() OVERRIDE; | 25 virtual void TearDown() override; |
| 26 | 26 |
| 27 PluginInstaller* installer() { return installer_.get(); } | 27 PluginInstaller* installer() { return installer_.get(); } |
| 28 | 28 |
| 29 scoped_ptr<content::MockDownloadItem> CreateMockDownloadItem(); | 29 scoped_ptr<content::MockDownloadItem> CreateMockDownloadItem(); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 scoped_ptr<PluginInstaller> installer_; | 32 scoped_ptr<PluginInstaller> installer_; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 PluginInstallerTest::PluginInstallerTest() { | 35 PluginInstallerTest::PluginInstallerTest() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 61 download_started_(false), | 61 download_started_(false), |
| 62 download_finished_(false), | 62 download_finished_(false), |
| 63 download_cancelled_(false) {} | 63 download_cancelled_(false) {} |
| 64 | 64 |
| 65 bool download_started() const { return download_started_; } | 65 bool download_started() const { return download_started_; } |
| 66 bool download_finished() const { return download_finished_; } | 66 bool download_finished() const { return download_finished_; } |
| 67 bool download_cancelled() const { return download_cancelled_; } | 67 bool download_cancelled() const { return download_cancelled_; } |
| 68 const std::string& download_error() const { return download_error_; } | 68 const std::string& download_error() const { return download_error_; } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 virtual void DownloadStarted() OVERRIDE { download_started_ = true; } | 71 virtual void DownloadStarted() override { download_started_ = true; } |
| 72 virtual void DownloadFinished() OVERRIDE { download_finished_ = true; } | 72 virtual void DownloadFinished() override { download_finished_ = true; } |
| 73 virtual void DownloadError(const std::string& message) OVERRIDE { | 73 virtual void DownloadError(const std::string& message) override { |
| 74 download_error_ = message; | 74 download_error_ = message; |
| 75 } | 75 } |
| 76 virtual void DownloadCancelled() OVERRIDE { download_cancelled_ = true; } | 76 virtual void DownloadCancelled() override { download_cancelled_ = true; } |
| 77 | 77 |
| 78 bool download_started_; | 78 bool download_started_; |
| 79 bool download_finished_; | 79 bool download_finished_; |
| 80 std::string download_error_; | 80 std::string download_error_; |
| 81 bool download_cancelled_; | 81 bool download_cancelled_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // Action for invoking the OnStartedCallback of DownloadURLParameters object | 84 // Action for invoking the OnStartedCallback of DownloadURLParameters object |
| 85 // which is assumed to be pointed to by arg0. | 85 // which is assumed to be pointed to by arg0. |
| 86 ACTION_P2(InvokeOnStartedCallback, download_item, interrupt_reason) { | 86 ACTION_P2(InvokeOnStartedCallback, download_item, interrupt_reason) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 EXPECT_CALL(*download_item, GetState()) | 180 EXPECT_CALL(*download_item, GetState()) |
| 181 .WillOnce(testing::Return(content::DownloadItem::INTERRUPTED)); | 181 .WillOnce(testing::Return(content::DownloadItem::INTERRUPTED)); |
| 182 EXPECT_CALL(*download_item, GetLastReason()).WillOnce( | 182 EXPECT_CALL(*download_item, GetLastReason()).WillOnce( |
| 183 testing::Return(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED)); | 183 testing::Return(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED)); |
| 184 download_item->NotifyObserversDownloadUpdated(); | 184 download_item->NotifyObserversDownloadUpdated(); |
| 185 | 185 |
| 186 EXPECT_TRUE(installer_observer.download_started()); | 186 EXPECT_TRUE(installer_observer.download_started()); |
| 187 EXPECT_FALSE(installer_observer.download_finished()); | 187 EXPECT_FALSE(installer_observer.download_finished()); |
| 188 EXPECT_EQ("NETWORK_FAILED", installer_observer.download_error()); | 188 EXPECT_EQ("NETWORK_FAILED", installer_observer.download_error()); |
| 189 } | 189 } |
| OLD | NEW |