| 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 "chrome/test/base/test_url_request_context_getter.h" | |
| 18 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 20 #include "content/test/test_browser_thread.h" | 19 #include "content/test/test_browser_thread.h" |
| 21 #include "content/public/common/url_fetcher.h" | 20 #include "content/public/common/url_fetcher.h" |
| 22 #include "content/test/test_notification_tracker.h" | 21 #include "content/test/test_notification_tracker.h" |
| 23 | |
| 24 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 25 #include "libxml/globals.h" | 23 #include "libxml/globals.h" |
| 26 | 24 #include "net/url_request/url_request_test_util.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 26 |
| 29 using content::BrowserThread; | 27 using content::BrowserThread; |
| 30 | 28 |
| 31 namespace { | 29 namespace { |
| 32 // Overrides some of the component updater behaviors so it is easier to test | 30 // Overrides some of the component updater behaviors so it is easier to test |
| 33 // and loops faster. In actual usage it takes hours do to a full cycle. | 31 // and loops faster. In actual usage it takes hours do to a full cycle. |
| 34 class TestConfigurator : public ComponentUpdateService::Configurator { | 32 class TestConfigurator : public ComponentUpdateService::Configurator { |
| 35 public: | 33 public: |
| 36 TestConfigurator() : times_(1) { | 34 TestConfigurator() : times_(1) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 return 0; | 56 return 0; |
| 59 } | 57 } |
| 60 | 58 |
| 61 virtual GURL UpdateUrl() OVERRIDE { return GURL("http://localhost/upd"); } | 59 virtual GURL UpdateUrl() OVERRIDE { return GURL("http://localhost/upd"); } |
| 62 | 60 |
| 63 virtual const char* ExtraRequestParams() OVERRIDE { return "extra=foo"; } | 61 virtual const char* ExtraRequestParams() OVERRIDE { return "extra=foo"; } |
| 64 | 62 |
| 65 virtual size_t UrlSizeLimit() OVERRIDE { return 256; } | 63 virtual size_t UrlSizeLimit() OVERRIDE { return 256; } |
| 66 | 64 |
| 67 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { | 65 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { |
| 68 return new TestURLRequestContextGetter(); | 66 return new TestURLRequestContextGetter( |
| 67 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 // Don't use the utility process to decode files. | 70 // Don't use the utility process to decode files. |
| 72 virtual bool InProcess() OVERRIDE { return true; } | 71 virtual bool InProcess() OVERRIDE { return true; } |
| 73 | 72 |
| 74 virtual void OnEvent(Events event, int extra) OVERRIDE { } | 73 virtual void OnEvent(Events event, int extra) OVERRIDE { } |
| 75 | 74 |
| 76 // Set how many update checks are called, the default value is just once. | 75 // Set how many update checks are called, the default value is just once. |
| 77 void SetLoopCount(int times) { times_ = times; } | 76 void SetLoopCount(int times) { times_ = times; } |
| 78 | 77 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 test_configurator()->SetLoopCount(1); | 406 test_configurator()->SetLoopCount(1); |
| 408 component_updater()->Start(); | 407 component_updater()->Start(); |
| 409 message_loop.Run(); | 408 message_loop.Run(); |
| 410 | 409 |
| 411 EXPECT_EQ(1, interceptor->hit_count()); | 410 EXPECT_EQ(1, interceptor->hit_count()); |
| 412 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); | 411 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); |
| 413 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); | 412 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); |
| 414 | 413 |
| 415 component_updater()->Stop(); | 414 component_updater()->Stop(); |
| 416 } | 415 } |
| OLD | NEW |