Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: chrome/browser/component_updater/test/component_updater_service_unittest.cc

Issue 292203002: Define and implement an interface for on-demand component updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 RunThreadsUntilIdle(); 240 RunThreadsUntilIdle();
241 } 241 }
242 242
243 void ComponentUpdaterTest::RunThreadsUntilIdle() { 243 void ComponentUpdaterTest::RunThreadsUntilIdle() {
244 base::RunLoop().RunUntilIdle(); 244 base::RunLoop().RunUntilIdle();
245 } 245 }
246 246
247 ComponentUpdateService::Status OnDemandTester::OnDemand( 247 ComponentUpdateService::Status OnDemandTester::OnDemand(
248 ComponentUpdateService* cus, 248 ComponentUpdateService* cus,
249 const std::string& component_id) { 249 const std::string& component_id) {
250 return cus->OnDemandUpdate(component_id); 250 return cus->GetOnDemandUpdater().OnDemandUpdate(component_id);
251 } 251 }
252 252
253 // Verify that our test fixture work and the component updater can 253 // Verify that our test fixture work and the component updater can
254 // be created and destroyed with no side effects. 254 // be created and destroyed with no side effects.
255 TEST_F(ComponentUpdaterTest, VerifyFixture) { 255 TEST_F(ComponentUpdaterTest, VerifyFixture) {
256 EXPECT_TRUE(component_updater() != NULL); 256 EXPECT_TRUE(component_updater() != NULL);
257 } 257 }
258 258
259 // Verify that the component updater can be caught in a quick 259 // Verify that the component updater can be caught in a quick
260 // start-shutdown situation. Failure of this test will be a crash. 260 // start-shutdown situation. Failure of this test will be a crash.
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 ComponentUpdateService* cus, 1289 ComponentUpdateService* cus,
1290 TestResourceController* controller, 1290 TestResourceController* controller,
1291 const char* crx_id) { 1291 const char* crx_id) {
1292 net::TestURLRequestContext context; 1292 net::TestURLRequestContext context;
1293 net::TestURLRequest url_request(GURL("http://foo.example.com/thing.bin"), 1293 net::TestURLRequest url_request(GURL("http://foo.example.com/thing.bin"),
1294 net::DEFAULT_PRIORITY, 1294 net::DEFAULT_PRIORITY,
1295 NULL, 1295 NULL,
1296 &context); 1296 &context);
1297 1297
1298 content::ResourceThrottle* rt = 1298 content::ResourceThrottle* rt =
1299 cus->GetOnDemandResourceThrottle(&url_request, crx_id); 1299 cus->GetOnDemandUpdater().GetOnDemandResourceThrottle(&url_request,
1300 crx_id);
1300 rt->set_controller_for_testing(controller); 1301 rt->set_controller_for_testing(controller);
1301 controller->SetThrottle(rt); 1302 controller->SetThrottle(rt);
1302 return rt; 1303 return rt;
1303 } 1304 }
1304 1305
1305 void RequestAndDeleteResourceThrottle(ComponentUpdateService* cus, 1306 void RequestAndDeleteResourceThrottle(ComponentUpdateService* cus,
1306 const char* crx_id) { 1307 const char* crx_id) {
1307 // By requesting a throttle and deleting it immediately we ensure that we 1308 // By requesting a throttle and deleting it immediately we ensure that we
1308 // hit the case where the component updater tries to use the weak 1309 // hit the case where the component updater tries to use the weak
1309 // pointer to a dead Resource throttle. 1310 // pointer to a dead Resource throttle.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 component_updater()->RemoveObserver(&observer2); 1534 component_updater()->RemoveObserver(&observer2);
1534 1535
1535 test_configurator()->SetLoopCount(1); 1536 test_configurator()->SetLoopCount(1);
1536 component_updater()->Start(); 1537 component_updater()->Start();
1537 RunThreads(); 1538 RunThreads();
1538 1539
1539 component_updater()->Stop(); 1540 component_updater()->Stop();
1540 } 1541 }
1541 1542
1542 } // namespace component_updater 1543 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698