OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/test/component_updater_service_unitte
st.h" | 5 #include "chrome/browser/component_updater/test/component_updater_service_unitte
st.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 #if defined(OS_ANDROID) | 996 #if defined(OS_ANDROID) |
997 #define MAYBE_CheckFailedInstallPing DISABLED_CheckFailedInstallPing | 997 #define MAYBE_CheckFailedInstallPing DISABLED_CheckFailedInstallPing |
998 #else | 998 #else |
999 #define MAYBE_CheckFailedInstallPing CheckFailedInstallPing | 999 #define MAYBE_CheckFailedInstallPing CheckFailedInstallPing |
1000 #endif | 1000 #endif |
1001 // Verify that a failed installation causes an install failure ping. | 1001 // Verify that a failed installation causes an install failure ping. |
1002 TEST_F(ComponentUpdaterTest, MAYBE_CheckFailedInstallPing) { | 1002 TEST_F(ComponentUpdaterTest, MAYBE_CheckFailedInstallPing) { |
1003 // This test installer reports installation failure. | 1003 // This test installer reports installation failure. |
1004 class : public TestInstaller { | 1004 class : public TestInstaller { |
1005 virtual bool Install(const base::DictionaryValue& manifest, | 1005 virtual bool Install(const base::DictionaryValue& manifest, |
1006 const base::FilePath& unpack_path) OVERRIDE { | 1006 const base::FilePath& unpack_path) override { |
1007 ++install_count_; | 1007 ++install_count_; |
1008 base::DeleteFile(unpack_path, true); | 1008 base::DeleteFile(unpack_path, true); |
1009 return false; | 1009 return false; |
1010 } | 1010 } |
1011 } installer; | 1011 } installer; |
1012 | 1012 |
1013 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 1013 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
1014 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 1014 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
1015 EXPECT_TRUE(post_interceptor_->ExpectRequest(new PartialMatch("event"))); | 1015 EXPECT_TRUE(post_interceptor_->ExpectRequest(new PartialMatch("event"))); |
1016 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 1016 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 } | 1202 } |
1203 | 1203 |
1204 void RequestAndDeleteResourceThrottle(ComponentUpdateService* cus, | 1204 void RequestAndDeleteResourceThrottle(ComponentUpdateService* cus, |
1205 const char* crx_id) { | 1205 const char* crx_id) { |
1206 // By requesting a throttle and deleting it immediately we ensure that we | 1206 // By requesting a throttle and deleting it immediately we ensure that we |
1207 // hit the case where the component updater tries to use the weak | 1207 // hit the case where the component updater tries to use the weak |
1208 // pointer to a dead Resource throttle. | 1208 // pointer to a dead Resource throttle. |
1209 class NoCallResourceController : public TestResourceController { | 1209 class NoCallResourceController : public TestResourceController { |
1210 public: | 1210 public: |
1211 virtual ~NoCallResourceController() {} | 1211 virtual ~NoCallResourceController() {} |
1212 virtual void Cancel() OVERRIDE { CHECK(false); } | 1212 virtual void Cancel() override { CHECK(false); } |
1213 virtual void CancelAndIgnore() OVERRIDE { CHECK(false); } | 1213 virtual void CancelAndIgnore() override { CHECK(false); } |
1214 virtual void CancelWithError(int error_code) OVERRIDE { CHECK(false); } | 1214 virtual void CancelWithError(int error_code) override { CHECK(false); } |
1215 virtual void Resume() OVERRIDE { CHECK(false); } | 1215 virtual void Resume() override { CHECK(false); } |
1216 } controller; | 1216 } controller; |
1217 | 1217 |
1218 delete RequestTestResourceThrottle(cus, &controller, crx_id); | 1218 delete RequestTestResourceThrottle(cus, &controller, crx_id); |
1219 } | 1219 } |
1220 | 1220 |
1221 TEST_F(ComponentUpdaterTest, ResourceThrottleDeletedNoUpdate) { | 1221 TEST_F(ComponentUpdaterTest, ResourceThrottleDeletedNoUpdate) { |
1222 MockServiceObserver observer; | 1222 MockServiceObserver observer; |
1223 { | 1223 { |
1224 InSequence seq; | 1224 InSequence seq; |
1225 EXPECT_CALL(observer, | 1225 EXPECT_CALL(observer, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1271 |
1272 class CancelResourceController : public TestResourceController { | 1272 class CancelResourceController : public TestResourceController { |
1273 public: | 1273 public: |
1274 CancelResourceController() : throttle_(NULL), resume_called_(0) {} | 1274 CancelResourceController() : throttle_(NULL), resume_called_(0) {} |
1275 virtual ~CancelResourceController() { | 1275 virtual ~CancelResourceController() { |
1276 // Check that the throttle has been resumed by the time we | 1276 // Check that the throttle has been resumed by the time we |
1277 // exit the test. | 1277 // exit the test. |
1278 CHECK_EQ(1, resume_called_); | 1278 CHECK_EQ(1, resume_called_); |
1279 delete throttle_; | 1279 delete throttle_; |
1280 } | 1280 } |
1281 virtual void Cancel() OVERRIDE { CHECK(false); } | 1281 virtual void Cancel() override { CHECK(false); } |
1282 virtual void CancelAndIgnore() OVERRIDE { CHECK(false); } | 1282 virtual void CancelAndIgnore() override { CHECK(false); } |
1283 virtual void CancelWithError(int error_code) OVERRIDE { CHECK(false); } | 1283 virtual void CancelWithError(int error_code) override { CHECK(false); } |
1284 virtual void Resume() OVERRIDE { | 1284 virtual void Resume() override { |
1285 BrowserThread::PostTask(BrowserThread::IO, | 1285 BrowserThread::PostTask(BrowserThread::IO, |
1286 FROM_HERE, | 1286 FROM_HERE, |
1287 base::Bind(&CancelResourceController::ResumeCalled, | 1287 base::Bind(&CancelResourceController::ResumeCalled, |
1288 base::Unretained(this))); | 1288 base::Unretained(this))); |
1289 } | 1289 } |
1290 virtual void SetThrottle(content::ResourceThrottle* throttle) OVERRIDE { | 1290 virtual void SetThrottle(content::ResourceThrottle* throttle) override { |
1291 throttle_ = throttle; | 1291 throttle_ = throttle; |
1292 bool defer = false; | 1292 bool defer = false; |
1293 // Initially the throttle is blocked. The CUS needs to run a | 1293 // Initially the throttle is blocked. The CUS needs to run a |
1294 // task on the UI thread to decide if it should unblock. | 1294 // task on the UI thread to decide if it should unblock. |
1295 throttle_->WillStartRequest(&defer); | 1295 throttle_->WillStartRequest(&defer); |
1296 CHECK(defer); | 1296 CHECK(defer); |
1297 } | 1297 } |
1298 | 1298 |
1299 private: | 1299 private: |
1300 void ResumeCalled() { ++resume_called_; } | 1300 void ResumeCalled() { ++resume_called_; } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 component_updater()->RemoveObserver(&observer2); | 1493 component_updater()->RemoveObserver(&observer2); |
1494 | 1494 |
1495 test_configurator()->SetLoopCount(1); | 1495 test_configurator()->SetLoopCount(1); |
1496 component_updater()->Start(); | 1496 component_updater()->Start(); |
1497 RunThreads(); | 1497 RunThreads(); |
1498 | 1498 |
1499 component_updater()->Stop(); | 1499 component_updater()->Stop(); |
1500 } | 1500 } |
1501 | 1501 |
1502 } // namespace component_updater | 1502 } // namespace component_updater |
OLD | NEW |