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

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

Issue 1578083002: Implements an UpdateClient::SendUninstallPing API for the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « components/update_client/ping_manager.cc ('k') | components/update_client/update_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
6
5 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 9 #include "base/run_loop.h"
8 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
9 #include "base/version.h" 11 #include "base/version.h"
10 #include "components/update_client/crx_update_item.h" 12 #include "components/update_client/crx_update_item.h"
11 #include "components/update_client/ping_manager.h" 13 #include "components/update_client/ping_manager.h"
12 #include "components/update_client/test_configurator.h" 14 #include "components/update_client/test_configurator.h"
13 #include "components/update_client/url_request_post_interceptor.h" 15 #include "components/update_client/url_request_post_interceptor.h"
14 #include "net/url_request/url_request_test_util.h" 16 #include "net/url_request/url_request_test_util.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 interceptor_factory->CreateInterceptor(); 65 interceptor_factory->CreateInterceptor();
64 EXPECT_TRUE(interceptor); 66 EXPECT_TRUE(interceptor);
65 67
66 // Test eventresult="1" is sent for successful updates. 68 // Test eventresult="1" is sent for successful updates.
67 CrxUpdateItem item; 69 CrxUpdateItem item;
68 item.id = "abc"; 70 item.id = "abc";
69 item.state = CrxUpdateItem::State::kUpdated; 71 item.state = CrxUpdateItem::State::kUpdated;
70 item.previous_version = base::Version("1.0"); 72 item.previous_version = base::Version("1.0");
71 item.next_version = base::Version("2.0"); 73 item.next_version = base::Version("2.0");
72 74
73 ping_manager_->OnUpdateComplete(&item); 75 ping_manager_->SendPing(&item);
74 base::RunLoop().RunUntilIdle(); 76 base::RunLoop().RunUntilIdle();
75 77
76 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString(); 78 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
77 EXPECT_NE(string::npos, 79 EXPECT_NE(string::npos,
78 interceptor->GetRequests()[0].find( 80 interceptor->GetRequests()[0].find(
79 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">" 81 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">"
80 "<event eventtype=\"3\" eventresult=\"1\"/></app>")) 82 "<event eventtype=\"3\" eventresult=\"1\"/></app>"))
81 << interceptor->GetRequestsAsString(); 83 << interceptor->GetRequestsAsString();
82 interceptor->Reset(); 84 interceptor->Reset();
83 85
84 // Test eventresult="0" is sent for failed updates. 86 // Test eventresult="0" is sent for failed updates.
85 item = CrxUpdateItem(); 87 item = CrxUpdateItem();
86 item.id = "abc"; 88 item.id = "abc";
87 item.state = CrxUpdateItem::State::kNoUpdate; 89 item.state = CrxUpdateItem::State::kNoUpdate;
88 item.previous_version = base::Version("1.0"); 90 item.previous_version = base::Version("1.0");
89 item.next_version = base::Version("2.0"); 91 item.next_version = base::Version("2.0");
90 92
91 ping_manager_->OnUpdateComplete(&item); 93 ping_manager_->SendPing(&item);
92 base::RunLoop().RunUntilIdle(); 94 base::RunLoop().RunUntilIdle();
93 95
94 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString(); 96 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
95 EXPECT_NE(string::npos, 97 EXPECT_NE(string::npos,
96 interceptor->GetRequests()[0].find( 98 interceptor->GetRequests()[0].find(
97 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">" 99 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">"
98 "<event eventtype=\"3\" eventresult=\"0\"/></app>")) 100 "<event eventtype=\"3\" eventresult=\"0\"/></app>"))
99 << interceptor->GetRequestsAsString(); 101 << interceptor->GetRequestsAsString();
100 interceptor->Reset(); 102 interceptor->Reset();
101 103
102 // Test the error values and the fingerprints. 104 // Test the error values and the fingerprints.
103 item = CrxUpdateItem(); 105 item = CrxUpdateItem();
104 item.id = "abc"; 106 item.id = "abc";
105 item.state = CrxUpdateItem::State::kNoUpdate; 107 item.state = CrxUpdateItem::State::kNoUpdate;
106 item.previous_version = base::Version("1.0"); 108 item.previous_version = base::Version("1.0");
107 item.next_version = base::Version("2.0"); 109 item.next_version = base::Version("2.0");
108 item.previous_fp = "prev fp"; 110 item.previous_fp = "prev fp";
109 item.next_fp = "next fp"; 111 item.next_fp = "next fp";
110 item.error_category = 1; 112 item.error_category = 1;
111 item.error_code = 2; 113 item.error_code = 2;
112 item.extra_code1 = -1; 114 item.extra_code1 = -1;
113 item.diff_error_category = 10; 115 item.diff_error_category = 10;
114 item.diff_error_code = 20; 116 item.diff_error_code = 20;
115 item.diff_extra_code1 = -10; 117 item.diff_extra_code1 = -10;
116 item.diff_update_failed = true; 118 item.diff_update_failed = true;
117 item.crx_diffurls.push_back(GURL("http://host/path")); 119 item.crx_diffurls.push_back(GURL("http://host/path"));
118 120
119 ping_manager_->OnUpdateComplete(&item); 121 ping_manager_->SendPing(&item);
120 base::RunLoop().RunUntilIdle(); 122 base::RunLoop().RunUntilIdle();
121 123
122 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString(); 124 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
123 EXPECT_NE(string::npos, 125 EXPECT_NE(string::npos,
124 interceptor->GetRequests()[0].find( 126 interceptor->GetRequests()[0].find(
125 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">" 127 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">"
126 "<event eventtype=\"3\" eventresult=\"0\" errorcat=\"1\" " 128 "<event eventtype=\"3\" eventresult=\"0\" errorcat=\"1\" "
127 "errorcode=\"2\" extracode1=\"-1\" diffresult=\"0\" " 129 "errorcode=\"2\" extracode1=\"-1\" diffresult=\"0\" "
128 "differrorcat=\"10\" " 130 "differrorcat=\"10\" "
129 "differrorcode=\"20\" diffextracode1=\"-10\" " 131 "differrorcode=\"20\" diffextracode1=\"-10\" "
(...skipping 19 matching lines...) Expand all
149 151
150 download_metrics = CrxDownloader::DownloadMetrics(); 152 download_metrics = CrxDownloader::DownloadMetrics();
151 download_metrics.url = GURL("http://host2/path2"); 153 download_metrics.url = GURL("http://host2/path2");
152 download_metrics.downloader = CrxDownloader::DownloadMetrics::kBits; 154 download_metrics.downloader = CrxDownloader::DownloadMetrics::kBits;
153 download_metrics.error = 0; 155 download_metrics.error = 0;
154 download_metrics.downloaded_bytes = 1230; 156 download_metrics.downloaded_bytes = 1230;
155 download_metrics.total_bytes = 4560; 157 download_metrics.total_bytes = 4560;
156 download_metrics.download_time_ms = 9870; 158 download_metrics.download_time_ms = 9870;
157 item.download_metrics.push_back(download_metrics); 159 item.download_metrics.push_back(download_metrics);
158 160
159 ping_manager_->OnUpdateComplete(&item); 161 ping_manager_->SendPing(&item);
160 base::RunLoop().RunUntilIdle(); 162 base::RunLoop().RunUntilIdle();
161 163
162 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString(); 164 EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
163 EXPECT_NE( 165 EXPECT_NE(
164 string::npos, 166 string::npos,
165 interceptor->GetRequests()[0].find( 167 interceptor->GetRequests()[0].find(
166 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">" 168 "<app appid=\"abc\" version=\"1.0\" nextversion=\"2.0\">"
167 "<event eventtype=\"3\" eventresult=\"1\"/>" 169 "<event eventtype=\"3\" eventresult=\"1\"/>"
168 "<event eventtype=\"14\" eventresult=\"0\" downloader=\"direct\" " 170 "<event eventtype=\"14\" eventresult=\"0\" downloader=\"direct\" "
169 "errorcode=\"-1\" url=\"http://host1/path1\" downloaded=\"123\" " 171 "errorcode=\"-1\" url=\"http://host1/path1\" downloaded=\"123\" "
170 "total=\"456\" download_time_ms=\"987\"/>" 172 "total=\"456\" download_time_ms=\"987\"/>"
171 "<event eventtype=\"14\" eventresult=\"1\" downloader=\"bits\" " 173 "<event eventtype=\"14\" eventresult=\"1\" downloader=\"bits\" "
172 "url=\"http://host2/path2\" downloaded=\"1230\" total=\"4560\" " 174 "url=\"http://host2/path2\" downloaded=\"1230\" total=\"4560\" "
173 "download_time_ms=\"9870\"/></app>")) 175 "download_time_ms=\"9870\"/></app>"))
174 << interceptor->GetRequestsAsString(); 176 << interceptor->GetRequestsAsString();
175 interceptor->Reset(); 177 interceptor->Reset();
176 } 178 }
177 179
178 } // namespace update_client 180 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/ping_manager.cc ('k') | components/update_client/update_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698