OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <utility> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/component_updater/component_updater_service.h" |
| 14 #include "chrome/browser/component_updater/test/component_patcher_mock.h" |
| 15 #include "content/public/test/test_notification_tracker.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 |
| 18 using content::TestNotificationTracker; |
| 19 |
| 20 class GURL; |
| 21 class TestInstaller; |
| 22 |
| 23 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and |
| 24 // the RSA public key the following hash: |
| 25 const uint8 jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec, |
| 26 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5, |
| 27 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4, |
| 28 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40}; |
| 29 // component 2 has extension id "abagagagagagagagagagagagagagagag", and |
| 30 // the RSA public key the following hash: |
| 31 const uint8 abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
| 32 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
| 33 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
| 34 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01}; |
| 35 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and |
| 36 // the RSA public key the following hash: |
| 37 const uint8 ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e, |
| 38 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2, |
| 39 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b, |
| 40 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17}; |
| 41 |
| 42 class TestConfigurator : public ComponentUpdateService::Configurator { |
| 43 public: |
| 44 explicit TestConfigurator(); |
| 45 |
| 46 virtual ~TestConfigurator(); |
| 47 |
| 48 virtual int InitialDelay() OVERRIDE; |
| 49 |
| 50 typedef std::pair<CrxComponent*, int> CheckAtLoopCount; |
| 51 |
| 52 virtual int NextCheckDelay() OVERRIDE; |
| 53 |
| 54 virtual int StepDelay() OVERRIDE; |
| 55 |
| 56 virtual int MinimumReCheckWait() OVERRIDE; |
| 57 |
| 58 virtual int OnDemandDelay() OVERRIDE; |
| 59 |
| 60 virtual GURL UpdateUrl(CrxComponent::UrlSource source) OVERRIDE; |
| 61 |
| 62 virtual const char* ExtraRequestParams() OVERRIDE; |
| 63 |
| 64 virtual size_t UrlSizeLimit() OVERRIDE; |
| 65 |
| 66 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; |
| 67 |
| 68 // Don't use the utility process to decode files. |
| 69 virtual bool InProcess() OVERRIDE; |
| 70 |
| 71 virtual void OnEvent(Events event, int extra) OVERRIDE; |
| 72 |
| 73 virtual ComponentPatcher* CreateComponentPatcher() OVERRIDE; |
| 74 |
| 75 virtual bool DeltasEnabled() const OVERRIDE; |
| 76 |
| 77 void SetLoopCount(int times); |
| 78 |
| 79 void SetRecheckTime(int seconds); |
| 80 |
| 81 void SetOnDemandTime(int seconds); |
| 82 |
| 83 void AddComponentToCheck(CrxComponent* com, int at_loop_iter); |
| 84 |
| 85 void SetComponentUpdateService(ComponentUpdateService* cus); |
| 86 |
| 87 private: |
| 88 int times_; |
| 89 int recheck_time_; |
| 90 int ondemand_time_; |
| 91 |
| 92 std::list<CheckAtLoopCount> components_to_check_; |
| 93 ComponentUpdateService* cus_; |
| 94 }; |
| 95 |
| 96 class ComponentUpdaterTest : public testing::Test { |
| 97 public: |
| 98 enum TestComponents { |
| 99 kTestComponent_abag, |
| 100 kTestComponent_jebg, |
| 101 kTestComponent_ihfo, |
| 102 }; |
| 103 |
| 104 ComponentUpdaterTest(); |
| 105 |
| 106 virtual ~ComponentUpdaterTest(); |
| 107 |
| 108 virtual void TearDown(); |
| 109 |
| 110 ComponentUpdateService* component_updater(); |
| 111 |
| 112 // Makes the full path to a component updater test file. |
| 113 const base::FilePath test_file(const char* file); |
| 114 |
| 115 TestNotificationTracker& notification_tracker(); |
| 116 |
| 117 TestConfigurator* test_configurator(); |
| 118 |
| 119 ComponentUpdateService::Status RegisterComponent(CrxComponent* com, |
| 120 TestComponents component, |
| 121 const Version& version, |
| 122 TestInstaller* installer); |
| 123 |
| 124 private: |
| 125 scoped_ptr<ComponentUpdateService> component_updater_; |
| 126 base::FilePath test_data_dir_; |
| 127 TestNotificationTracker notification_tracker_; |
| 128 TestConfigurator* test_config_; |
| 129 }; |
| 130 |
| 131 const char expected_crx_url[] = |
| 132 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; |
| 133 |
| 134 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT
EST_H_ |
OLD | NEW |