| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 int times_; | 88 int times_; |
| 89 int recheck_time_; | 89 int recheck_time_; |
| 90 int ondemand_time_; | 90 int ondemand_time_; |
| 91 | 91 |
| 92 std::list<CheckAtLoopCount> components_to_check_; | 92 std::list<CheckAtLoopCount> components_to_check_; |
| 93 ComponentUpdateService* cus_; | 93 ComponentUpdateService* cus_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // TestNotificationTracker does not keep a deep copy of the source, |
| 97 // so we will need to for testing. The test does not inspect the observations |
| 98 // as they occur -- only post mortem. Otherwise, the tester will end up |
| 99 // dereferencing an already-deallocated pointer. |
| 100 class TestUpdateNotificationTracker : public TestNotificationTracker { |
| 101 public: |
| 102 TestUpdateNotificationTracker(); |
| 103 virtual ~TestUpdateNotificationTracker(); |
| 104 |
| 105 std::string SourceAt(size_t num); |
| 106 |
| 107 virtual void Reset() OVERRIDE; |
| 108 |
| 109 private: |
| 110 virtual void Observe(int type, |
| 111 const content::NotificationSource& source, |
| 112 const content::NotificationDetails& details) OVERRIDE; |
| 113 |
| 114 std::vector<std::string> sources_; |
| 115 }; |
| 116 |
| 96 class ComponentUpdaterTest : public testing::Test { | 117 class ComponentUpdaterTest : public testing::Test { |
| 97 public: | 118 public: |
| 98 enum TestComponents { | 119 enum TestComponents { |
| 99 kTestComponent_abag, | 120 kTestComponent_abag, |
| 100 kTestComponent_jebg, | 121 kTestComponent_jebg, |
| 101 kTestComponent_ihfo, | 122 kTestComponent_ihfo, |
| 102 }; | 123 }; |
| 103 | 124 |
| 104 ComponentUpdaterTest(); | 125 ComponentUpdaterTest(); |
| 105 | 126 |
| 106 virtual ~ComponentUpdaterTest(); | 127 virtual ~ComponentUpdaterTest(); |
| 107 | 128 |
| 108 virtual void TearDown(); | 129 virtual void TearDown(); |
| 109 | 130 |
| 110 ComponentUpdateService* component_updater(); | 131 ComponentUpdateService* component_updater(); |
| 111 | 132 |
| 112 // Makes the full path to a component updater test file. | 133 // Makes the full path to a component updater test file. |
| 113 const base::FilePath test_file(const char* file); | 134 const base::FilePath test_file(const char* file); |
| 114 | 135 |
| 115 TestNotificationTracker& notification_tracker(); | 136 TestUpdateNotificationTracker& notification_tracker(); |
| 116 | 137 |
| 117 TestConfigurator* test_configurator(); | 138 TestConfigurator* test_configurator(); |
| 118 | 139 |
| 119 ComponentUpdateService::Status RegisterComponent(CrxComponent* com, | 140 ComponentUpdateService::Status RegisterComponent(CrxComponent* com, |
| 120 TestComponents component, | 141 TestComponents component, |
| 121 const Version& version, | 142 const Version& version, |
| 122 TestInstaller* installer); | 143 TestInstaller* installer); |
| 123 | 144 |
| 124 private: | 145 private: |
| 125 scoped_ptr<ComponentUpdateService> component_updater_; | 146 scoped_ptr<ComponentUpdateService> component_updater_; |
| 126 base::FilePath test_data_dir_; | 147 base::FilePath test_data_dir_; |
| 127 TestNotificationTracker notification_tracker_; | 148 TestUpdateNotificationTracker notification_tracker_; |
| 128 TestConfigurator* test_config_; | 149 TestConfigurator* test_config_; |
| 129 }; | 150 }; |
| 130 | 151 |
| 131 const char expected_crx_url[] = | 152 const char expected_crx_url[] = |
| 132 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; | 153 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; |
| 133 | 154 |
| 134 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT
EST_H_ | 155 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT
EST_H_ |
| OLD | NEW |