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

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

Issue 18516010: Implemented completion pings for component updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 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 #include <list> 5 #include <list>
6 #include <utility> 6 #include <utility>
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 22 matching lines...) Expand all
33 #include "net/url_request/url_request_test_util.h" 33 #include "net/url_request/url_request_test_util.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "url/gurl.h" 35 #include "url/gurl.h"
36 36
37 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::TestNotificationTracker; 38 using content::TestNotificationTracker;
39 39
40 // Verify that we can download and install a component and a differential 40 // Verify that we can download and install a component and a differential
41 // update to that component. We do three loops; the final loop should do 41 // update to that component. We do three loops; the final loop should do
42 // nothing. 42 // nothing.
43 // We also check that exactly 5 network requests are issued: 43 // We also check that exactly 5 non-ping network requests are issued:
44 // 1- update check (response: v1 available) 44 // 1- update check (response: v1 available)
45 // 2- download crx (v1) 45 // 2- download crx (v1)
46 // 3- update check (response: v2 available) 46 // 3- update check (response: v2 available)
47 // 4- download differential crx (v1 to v2) 47 // 4- download differential crx (v1 to v2)
48 // 5- update check (response: no further update available) 48 // 5- update check (response: no further update available)
49 // There should be two pings, one for each update. The second will bear a
50 // diffresult=1, while the first will not.
49 TEST_F(ComponentUpdaterTest, DifferentialUpdate) { 51 TEST_F(ComponentUpdaterTest, DifferentialUpdate) {
50 base::MessageLoop message_loop; 52 base::MessageLoop message_loop;
51 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 53 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
52 content::TestBrowserThread file_thread(BrowserThread::FILE); 54 content::TestBrowserThread file_thread(BrowserThread::FILE);
53 content::TestBrowserThread io_thread(BrowserThread::IO); 55 content::TestBrowserThread io_thread(BrowserThread::IO);
54 56
55 io_thread.StartIOThread(); 57 io_thread.StartIOThread();
56 file_thread.Start(); 58 file_thread.Start();
57 59
60 std::map<std::string, std::string> map;
61 map.insert(std::pair<std::string, std::string>("eventtype", "\"3\""));
62 map.insert(std::pair<std::string, std::string>("eventresult", "\"1\""));
63 map.insert(std::pair<std::string, std::string>("diffresult", "\"1\""));
64 PingChecker ping_checker(map);
65 URLRequestPostInterceptor post_interceptor(&ping_checker);
58 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 66 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
59 67
60 VersionedTestInstaller installer; 68 VersionedTestInstaller installer;
61 CrxComponent com; 69 CrxComponent com;
62 RegisterComponent(&com, kTestComponent_ihfo, Version("0.0"), &installer); 70 RegisterComponent(&com, kTestComponent_ihfo, Version("0.0"), &installer);
63 71
64 const GURL expected_update_url_0( 72 const GURL expected_update_url_0(
65 "http://localhost/upd?extra=foo" 73 "http://localhost/upd?extra=foo"
66 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D0.0%26fp%3D%26uc"); 74 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D0.0%26fp%3D%26uc");
67 const GURL expected_update_url_1( 75 const GURL expected_update_url_1(
(...skipping 20 matching lines...) Expand all
88 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx")); 96 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx"));
89 97
90 test_configurator()->SetLoopCount(3); 98 test_configurator()->SetLoopCount(3);
91 99
92 component_updater()->Start(); 100 component_updater()->Start();
93 message_loop.Run(); 101 message_loop.Run();
94 102
95 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); 103 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error());
96 EXPECT_EQ(2, static_cast<TestInstaller*>(com.installer)->install_count()); 104 EXPECT_EQ(2, static_cast<TestInstaller*>(com.installer)->install_count());
97 105
106 EXPECT_EQ(1, ping_checker.NumHits());
107 EXPECT_EQ(1, ping_checker.NumMisses());
98 EXPECT_EQ(5, interceptor.GetHitCount()); 108 EXPECT_EQ(5, interceptor.GetHitCount());
99 109
100 component_updater()->Stop(); 110 component_updater()->Stop();
101 } 111 }
112
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698