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

Side by Side Diff: components/update_client/update_client_unittest.cc

Issue 2831473002: Add a callback parameter to UpdateClient::SendUninstallPing. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2226
2227 std::vector<std::string> empty_id_list; 2227 std::vector<std::string> empty_id_list;
2228 base::RunLoop runloop; 2228 base::RunLoop runloop;
2229 update_client->Update( 2229 update_client->Update(
2230 empty_id_list, base::Bind(&DataCallbackFake::Callback), 2230 empty_id_list, base::Bind(&DataCallbackFake::Callback),
2231 base::Bind(&CompletionCallbackFake::Callback, runloop.QuitClosure())); 2231 base::Bind(&CompletionCallbackFake::Callback, runloop.QuitClosure()));
2232 runloop.Run(); 2232 runloop.Run();
2233 } 2233 }
2234 2234
2235 TEST_F(UpdateClientTest, SendUninstallPing) { 2235 TEST_F(UpdateClientTest, SendUninstallPing) {
2236 class CompletionCallbackFake {
2237 public:
2238 static void Callback(const base::Closure& quit_closure, Error error) {
2239 quit_closure.Run();
2240 }
2241 };
2242
2236 class FakeUpdateChecker : public UpdateChecker { 2243 class FakeUpdateChecker : public UpdateChecker {
2237 public: 2244 public:
2238 static std::unique_ptr<UpdateChecker> Create( 2245 static std::unique_ptr<UpdateChecker> Create(
2239 const scoped_refptr<Configurator>& config, 2246 const scoped_refptr<Configurator>& config,
2240 PersistedData* metadata) { 2247 PersistedData* metadata) {
2241 return nullptr; 2248 return nullptr;
2242 } 2249 }
2243 2250
2244 bool CheckForUpdates( 2251 bool CheckForUpdates(
2245 const IdToCrxUpdateItemMap& items_to_check, 2252 const IdToCrxUpdateItemMap& items_to_check,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 EXPECT_EQ(base::Version("0.0"), ping_items[0].next_version); 2286 EXPECT_EQ(base::Version("0.0"), ping_items[0].next_version);
2280 EXPECT_EQ(10, ping_items[0].extra_code1); 2287 EXPECT_EQ(10, ping_items[0].extra_code1);
2281 } 2288 }
2282 }; 2289 };
2283 2290
2284 std::unique_ptr<PingManager> ping_manager(new FakePingManager(config())); 2291 std::unique_ptr<PingManager> ping_manager(new FakePingManager(config()));
2285 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( 2292 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl(
2286 config(), std::move(ping_manager), &FakeUpdateChecker::Create, 2293 config(), std::move(ping_manager), &FakeUpdateChecker::Create,
2287 &FakeCrxDownloader::Create)); 2294 &FakeCrxDownloader::Create));
2288 2295
2289 update_client->SendUninstallPing("jebgalgnebhfojomionfpkfelancnnkf", 2296 update_client->SendUninstallPing(
2290 base::Version("1.0"), 10); 2297 "jebgalgnebhfojomionfpkfelancnnkf", base::Version("1.0"), 10,
2298 base::Bind(&CompletionCallbackFake::Callback, quit_closure()));
2299
2300 RunThreads();
2291 } 2301 }
2292 2302
2293 TEST_F(UpdateClientTest, RetryAfter) { 2303 TEST_F(UpdateClientTest, RetryAfter) {
2294 class DataCallbackFake { 2304 class DataCallbackFake {
2295 public: 2305 public:
2296 static void Callback(const std::vector<std::string>& ids, 2306 static void Callback(const std::vector<std::string>& ids,
2297 std::vector<CrxComponent>* components) { 2307 std::vector<CrxComponent>* components) {
2298 CrxComponent crx; 2308 CrxComponent crx;
2299 crx.name = "test_jebg"; 2309 crx.name = "test_jebg";
2300 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash)); 2310 crx.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 update_client->Update( 2717 update_client->Update(
2708 ids, base::Bind(&DataCallbackFake::Callback), 2718 ids, base::Bind(&DataCallbackFake::Callback),
2709 base::Bind(&CompletionCallbackFake::Callback, quit_closure())); 2719 base::Bind(&CompletionCallbackFake::Callback, quit_closure()));
2710 2720
2711 RunThreads(); 2721 RunThreads();
2712 2722
2713 update_client->RemoveObserver(&observer); 2723 update_client->RemoveObserver(&observer);
2714 } 2724 }
2715 2725
2716 } // namespace update_client 2726 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_client_internal.h ('k') | extensions/browser/updater/update_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698