| 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/component_updater/component_updater_service.h" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/component_updater/component_updater_interceptor.h" | 14 #include "chrome/browser/component_updater/component_updater_interceptor.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/common/url_fetcher.h" | |
| 20 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
| 21 #include "content/public/test/test_notification_tracker.h" | 20 #include "content/public/test/test_notification_tracker.h" |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 #include "libxml/globals.h" | 22 #include "libxml/globals.h" |
| 23 #include "net/url_request/url_fetcher.h" |
| 24 #include "net/url_request/url_request_test_util.h" | 24 #include "net/url_request/url_request_test_util.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 using content::TestNotificationTracker; | 28 using content::TestNotificationTracker; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 // Overrides some of the component updater behaviors so it is easier to test | 31 // Overrides some of the component updater behaviors so it is easier to test |
| 32 // and loops faster. In actual usage it takes hours do to a full cycle. | 32 // and loops faster. In actual usage it takes hours do to a full cycle. |
| 33 class TestConfigurator : public ComponentUpdateService::Configurator { | 33 class TestConfigurator : public ComponentUpdateService::Configurator { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, | 151 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, |
| 152 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, | 152 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, |
| 153 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, | 153 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, |
| 154 chrome::NOTIFICATION_COMPONENT_UPDATE_READY | 154 chrome::NOTIFICATION_COMPONENT_UPDATE_READY |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 for (int ix = 0; ix != arraysize(notifications); ++ix) { | 157 for (int ix = 0; ix != arraysize(notifications); ++ix) { |
| 158 notification_tracker_.ListenFor( | 158 notification_tracker_.ListenFor( |
| 159 notifications[ix], content::NotificationService::AllSources()); | 159 notifications[ix], content::NotificationService::AllSources()); |
| 160 } | 160 } |
| 161 content::URLFetcher::SetEnableInterceptionForTests(true); | 161 net::URLFetcher::SetEnableInterceptionForTests(true); |
| 162 } | 162 } |
| 163 | 163 |
| 164 ~ComponentUpdaterTest() { | 164 ~ComponentUpdaterTest() { |
| 165 content::URLFetcher::SetEnableInterceptionForTests(false); | 165 net::URLFetcher::SetEnableInterceptionForTests(false); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TearDown() { | 168 void TearDown() { |
| 169 xmlCleanupGlobals(); | 169 xmlCleanupGlobals(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 ComponentUpdateService* component_updater() { | 172 ComponentUpdateService* component_updater() { |
| 173 return component_updater_.get(); | 173 return component_updater_.get(); |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 test_configurator()->SetLoopCount(1); | 408 test_configurator()->SetLoopCount(1); |
| 409 component_updater()->Start(); | 409 component_updater()->Start(); |
| 410 message_loop.Run(); | 410 message_loop.Run(); |
| 411 | 411 |
| 412 EXPECT_EQ(1, interceptor->hit_count()); | 412 EXPECT_EQ(1, interceptor->hit_count()); |
| 413 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); | 413 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); |
| 414 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); | 414 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); |
| 415 | 415 |
| 416 component_updater()->Stop(); | 416 component_updater()->Stop(); |
| 417 } | 417 } |
| OLD | NEW |