| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/component_updater/component_updater_interceptor.h" | 12 #include "chrome/browser/component_updater/component_updater_interceptor.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/test/base/test_url_request_context_getter.h" | 15 #include "chrome/test/base/test_url_request_context_getter.h" |
| 16 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
| 17 #include "content/common/net/url_fetcher.h" | 17 #include "content/common/net/url_fetcher.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/test/test_notification_tracker.h" | 20 #include "content/test/test_notification_tracker.h" |
| 21 | 21 |
| 22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 23 #include "libxml/globals.h" | 23 #include "libxml/globals.h" |
| 24 | 24 |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 // Overrides some of the component updater behaviors so it is easier to test | 28 // Overrides some of the component updater behaviors so it is easier to test |
| 29 // and loops faster. In actual usage it takes hours do to a full cycle. | 29 // and loops faster. In actual usage it takes hours do to a full cycle. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Subscribe to all component updater notifications. | 145 // Subscribe to all component updater notifications. |
| 146 const int notifications[] = { | 146 const int notifications[] = { |
| 147 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, | 147 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, |
| 148 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, | 148 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, |
| 149 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, | 149 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, |
| 150 chrome::NOTIFICATION_COMPONENT_UPDATE_READY | 150 chrome::NOTIFICATION_COMPONENT_UPDATE_READY |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 for (int ix = 0; ix != arraysize(notifications); ++ix) { | 153 for (int ix = 0; ix != arraysize(notifications); ++ix) { |
| 154 notification_tracker_.ListenFor(notifications[ix], | 154 notification_tracker_.ListenFor( |
| 155 NotificationService::AllSources()); | 155 notifications[ix], content::NotificationService::AllSources()); |
| 156 } | 156 } |
| 157 URLFetcher::enable_interception_for_tests(true); | 157 URLFetcher::enable_interception_for_tests(true); |
| 158 } | 158 } |
| 159 | 159 |
| 160 ~ComponentUpdaterTest() { | 160 ~ComponentUpdaterTest() { |
| 161 URLFetcher::enable_interception_for_tests(false); | 161 URLFetcher::enable_interception_for_tests(false); |
| 162 } | 162 } |
| 163 | 163 |
| 164 ComponentUpdateService* component_updater() { | 164 ComponentUpdateService* component_updater() { |
| 165 return component_updater_.get(); | 165 return component_updater_.get(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 test_configurator()->SetLoopCount(1); | 402 test_configurator()->SetLoopCount(1); |
| 403 component_updater()->Start(); | 403 component_updater()->Start(); |
| 404 message_loop.Run(); | 404 message_loop.Run(); |
| 405 | 405 |
| 406 EXPECT_EQ(1, interceptor->hit_count()); | 406 EXPECT_EQ(1, interceptor->hit_count()); |
| 407 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); | 407 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); |
| 408 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); | 408 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); |
| 409 | 409 |
| 410 component_updater()->Stop(); | 410 component_updater()->Stop(); |
| 411 } | 411 } |
| OLD | NEW |