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

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>
6 #include <utility>
7 #include "base/compiler_specific.h"
8 #include "base/file_util.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/message_loop.h"
12 #include "base/path_service.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/values.h"
16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/component_updater/component_updater_service.h" 5 #include "chrome/browser/component_updater/component_updater_service.h"
18 #include "chrome/browser/component_updater/test/component_patcher_mock.h"
19 #include "chrome/browser/component_updater/test/component_updater_service_unitte st.h" 6 #include "chrome/browser/component_updater/test/component_updater_service_unitte st.h"
20 #include "chrome/browser/component_updater/test/test_installer.h" 7 #include "chrome/browser/component_updater/test/test_installer.h"
21 #include "chrome/common/chrome_paths.h"
22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_service.h"
24 #include "content/public/test/test_browser_thread.h"
25 #include "content/public/test/test_notification_tracker.h"
26 #include "content/test/net/url_request_prepackaged_interceptor.h" 8 #include "content/test/net/url_request_prepackaged_interceptor.h"
27 #include "libxml/globals.h"
28 #include "net/base/upload_bytes_element_reader.h"
29 #include "net/url_request/url_fetcher.h"
30 #include "net/url_request/url_request.h"
31 #include "net/url_request/url_request_filter.h"
32 #include "net/url_request/url_request_simple_job.h"
33 #include "net/url_request/url_request_test_util.h"
34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "url/gurl.h"
36
37 using content::BrowserThread;
38 using content::TestNotificationTracker;
39 9
40 // Verify that we can download and install a component and a differential 10 // 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 11 // update to that component. We do three loops; the final loop should do
42 // nothing. 12 // nothing.
43 // We also check that exactly 5 network requests are issued: 13 // We also check that exactly 5 non-ping network requests are issued:
44 // 1- update check (response: v1 available) 14 // 1- update check (response: v1 available)
45 // 2- download crx (v1) 15 // 2- download crx (v1)
46 // 3- update check (response: v2 available) 16 // 3- update check (response: v2 available)
47 // 4- download differential crx (v1 to v2) 17 // 4- download differential crx (v1 to v2)
48 // 5- update check (response: no further update available) 18 // 5- update check (response: no further update available)
19 // There should be two pings, one for each update. The second will bear a
20 // diffresult=1, while the first will not.
49 TEST_F(ComponentUpdaterTest, DifferentialUpdate) { 21 TEST_F(ComponentUpdaterTest, DifferentialUpdate) {
50 base::MessageLoop message_loop; 22 std::map<std::string, std::string> map;
51 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 23 map.insert(std::pair<std::string, std::string>("eventtype", "\"3\""));
52 content::TestBrowserThread file_thread(BrowserThread::FILE); 24 map.insert(std::pair<std::string, std::string>("eventresult", "\"1\""));
53 content::TestBrowserThread io_thread(BrowserThread::IO); 25 map.insert(std::pair<std::string, std::string>("diffresult", "\"1\""));
54 26 PingChecker ping_checker(map);
55 io_thread.StartIOThread(); 27 URLRequestPostInterceptor post_interceptor(&ping_checker);
56 file_thread.Start();
57
58 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 28 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
59 29
60 VersionedTestInstaller installer; 30 VersionedTestInstaller installer;
61 CrxComponent com; 31 CrxComponent com;
62 RegisterComponent(&com, kTestComponent_ihfo, Version("0.0"), &installer); 32 RegisterComponent(&com, kTestComponent_ihfo, Version("0.0"), &installer);
63 33
64 const GURL expected_update_url_0( 34 const GURL expected_update_url_0(
65 "http://localhost/upd?extra=foo" 35 "http://localhost/upd?extra=foo"
66 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D0.0%26fp%3D%26uc"); 36 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D0.0%26fp%3D%26uc");
67 const GURL expected_update_url_1( 37 const GURL expected_update_url_1(
(...skipping 15 matching lines...) Expand all
83 test_file("updatecheck_diff_reply_3.xml")); 53 test_file("updatecheck_diff_reply_3.xml"));
84 interceptor.SetResponse(expected_crx_url_1, 54 interceptor.SetResponse(expected_crx_url_1,
85 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1.crx")); 55 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1.crx"));
86 interceptor.SetResponse( 56 interceptor.SetResponse(
87 expected_crx_url_1_diff_2, 57 expected_crx_url_1_diff_2,
88 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx")); 58 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx"));
89 59
90 test_configurator()->SetLoopCount(3); 60 test_configurator()->SetLoopCount(3);
91 61
92 component_updater()->Start(); 62 component_updater()->Start();
93 message_loop.Run(); 63 message_loop_.Run();
94 64
95 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); 65 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error());
96 EXPECT_EQ(2, static_cast<TestInstaller*>(com.installer)->install_count()); 66 EXPECT_EQ(2, static_cast<TestInstaller*>(com.installer)->install_count());
97 67
68 EXPECT_EQ(1, ping_checker.NumHits());
69 EXPECT_EQ(1, ping_checker.NumMisses());
98 EXPECT_EQ(5, interceptor.GetHitCount()); 70 EXPECT_EQ(5, interceptor.GetHitCount());
99 71
100 component_updater()->Stop(); 72 component_updater()->Stop();
101 } 73 }
74
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698