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

Side by Side Diff: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc

Issue 1835833003: Disable V4UpdateProtocolManagerTests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <vector> 5 #include <vector>
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 EXPECT_EQ(expected.platform_type(), actual.platform_type()); 116 EXPECT_EQ(expected.platform_type(), actual.platform_type());
117 EXPECT_EQ(expected.response_type(), actual.response_type()); 117 EXPECT_EQ(expected.response_type(), actual.response_type());
118 EXPECT_EQ(expected.threat_entry_type(), actual.threat_entry_type()); 118 EXPECT_EQ(expected.threat_entry_type(), actual.threat_entry_type());
119 EXPECT_EQ(expected.threat_type(), actual.threat_type()); 119 EXPECT_EQ(expected.threat_type(), actual.threat_type());
120 120
121 // TODO(vakh): Test more fields from the proto. 121 // TODO(vakh): Test more fields from the proto.
122 } 122 }
123 } 123 }
124 124
125 // TODO(vakh): Add many more tests. 125 // TODO(vakh): Add many more tests.
126 126 #if defined(OS_ANDROID)
127 TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesErrorHandlingNetwork) { 127 // Flakes on Android: https://crbug.com/598412
128 #define MAYBE_TestGetUpdatesErrorHandlingNetwork \
129 DISABLED_TestGetUpdatesErrorHandlingNetwork
130 #else
131 #define MAYBE_TestGetUpdatesErrorHandlingNetwork \
132 TestGetUpdatesErrorHandlingNetwork
133 #endif
134 TEST_F(V4UpdateProtocolManagerTest, MAYBE_TestGetUpdatesErrorHandlingNetwork) {
128 net::TestURLFetcherFactory factory; 135 net::TestURLFetcherFactory factory;
129 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager()); 136 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager());
130 137
131 const std::vector<ListUpdateResponse> expected_lurs; 138 const std::vector<ListUpdateResponse> expected_lurs;
132 const base::hash_set<UpdateListIdentifier> lists_to_update; 139 const base::hash_set<UpdateListIdentifier> lists_to_update;
133 const base::hash_map<UpdateListIdentifier, std::string> current_list_states; 140 const base::hash_map<UpdateListIdentifier, std::string> current_list_states;
134 pm->GetUpdates(lists_to_update, current_list_states, 141 pm->GetUpdates(lists_to_update, current_list_states,
135 base::Bind(&ValidateGetUpdatesResults, expected_lurs)); 142 base::Bind(&ValidateGetUpdatesResults, expected_lurs));
136 143
137 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); 144 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
138 DCHECK(fetcher); 145 DCHECK(fetcher);
139 // Failed request status should result in error. 146 // Failed request status should result in error.
140 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED, 147 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED,
141 net::ERR_CONNECTION_RESET)); 148 net::ERR_CONNECTION_RESET));
142 fetcher->delegate()->OnURLFetchComplete(fetcher); 149 fetcher->delegate()->OnURLFetchComplete(fetcher);
143 150
144 // Should have recorded one error, but back off multiplier is unchanged. 151 // Should have recorded one error, but back off multiplier is unchanged.
145 EXPECT_EQ(1ul, pm->update_error_count_); 152 EXPECT_EQ(1ul, pm->update_error_count_);
146 EXPECT_EQ(1ul, pm->update_back_off_mult_); 153 EXPECT_EQ(1ul, pm->update_back_off_mult_);
147 } 154 }
148 155
149 TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesErrorHandlingResponseCode) { 156 #if defined(OS_ANDROID)
157 // Flakes on Android: https://crbug.com/598412
158 #define MAYBE_TestGetUpdatesErrorHandlingResponseCode \
159 DISABLED_TestGetUpdatesErrorHandlingResponseCode
160 #else
161 #define MAYBE_TestGetUpdatesErrorHandlingResponseCode \
162 TestGetUpdatesErrorHandlingResponseCode
163 #endif
164 TEST_F(V4UpdateProtocolManagerTest, \
165 MAYBE_TestGetUpdatesErrorHandlingResponseCode) {
150 net::TestURLFetcherFactory factory; 166 net::TestURLFetcherFactory factory;
151 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager()); 167 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager());
152 168
153 const std::vector<ListUpdateResponse> expected_lurs; 169 const std::vector<ListUpdateResponse> expected_lurs;
154 const base::hash_set<UpdateListIdentifier> lists_to_update; 170 const base::hash_set<UpdateListIdentifier> lists_to_update;
155 const base::hash_map<UpdateListIdentifier, std::string> current_list_states; 171 const base::hash_map<UpdateListIdentifier, std::string> current_list_states;
156 pm->GetUpdates(lists_to_update, current_list_states, 172 pm->GetUpdates(lists_to_update, current_list_states,
157 base::Bind(&ValidateGetUpdatesResults, expected_lurs)); 173 base::Bind(&ValidateGetUpdatesResults, expected_lurs));
158 174
159 175
160 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); 176 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
161 DCHECK(fetcher); 177 DCHECK(fetcher);
162 fetcher->set_status(net::URLRequestStatus()); 178 fetcher->set_status(net::URLRequestStatus());
163 // Response code of anything other than 200 should result in error. 179 // Response code of anything other than 200 should result in error.
164 fetcher->set_response_code(204); 180 fetcher->set_response_code(204);
165 fetcher->SetResponseString(GetStockV4UpdateResponse()); 181 fetcher->SetResponseString(GetStockV4UpdateResponse());
166 fetcher->delegate()->OnURLFetchComplete(fetcher); 182 fetcher->delegate()->OnURLFetchComplete(fetcher);
167 183
168 // Should have recorded one error, but back off multiplier is unchanged. 184 // Should have recorded one error, but back off multiplier is unchanged.
169 EXPECT_EQ(1ul, pm->update_error_count_); 185 EXPECT_EQ(1ul, pm->update_error_count_);
170 EXPECT_EQ(1ul, pm->update_back_off_mult_); 186 EXPECT_EQ(1ul, pm->update_back_off_mult_);
171 } 187 }
172 188
173 TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesNoError) { 189
190 #if defined(OS_ANDROID)
191 // Flakes on Android: https://crbug.com/598412
192 #define MAYBE_TestGetUpdatesNoError \
193 DISABLED_TestGetUpdatesNoError
194 #else
195 #define MAYBE_TestGetUpdatesNoError \
196 TestGetUpdatesNoError
197 #endif
198 TEST_F(V4UpdateProtocolManagerTest, MAYBE_TestGetUpdatesNoError) {
174 net::TestURLFetcherFactory factory; 199 net::TestURLFetcherFactory factory;
175 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager()); 200 scoped_ptr<V4UpdateProtocolManager> pm(CreateProtocolManager());
176 201
177 202
178 const std::vector<ListUpdateResponse> expected_lurs; 203 const std::vector<ListUpdateResponse> expected_lurs;
179 base::hash_set<UpdateListIdentifier> lists_to_update; 204 base::hash_set<UpdateListIdentifier> lists_to_update;
180 SetupListsToUpdate(&lists_to_update); 205 SetupListsToUpdate(&lists_to_update);
181 base::hash_map<UpdateListIdentifier, std::string> current_list_states; 206 base::hash_map<UpdateListIdentifier, std::string> current_list_states;
182 SetupCurrentListStates(lists_to_update, &current_list_states); 207 SetupCurrentListStates(lists_to_update, &current_list_states);
183 pm->GetUpdates(lists_to_update, current_list_states, 208 pm->GetUpdates(lists_to_update, current_list_states,
184 base::Bind(&ValidateGetUpdatesResults, expected_lurs)); 209 base::Bind(&ValidateGetUpdatesResults, expected_lurs));
185 ClearListsToUpdate(&lists_to_update); 210 ClearListsToUpdate(&lists_to_update);
186 211
187 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); 212 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
188 DCHECK(fetcher); 213 DCHECK(fetcher);
189 fetcher->set_status(net::URLRequestStatus()); 214 fetcher->set_status(net::URLRequestStatus());
190 fetcher->set_response_code(200); 215 fetcher->set_response_code(200);
191 fetcher->SetResponseString(GetStockV4UpdateResponse()); 216 fetcher->SetResponseString(GetStockV4UpdateResponse());
192 fetcher->delegate()->OnURLFetchComplete(fetcher); 217 fetcher->delegate()->OnURLFetchComplete(fetcher);
193 218
194 // No error, back off multiplier is unchanged. 219 // No error, back off multiplier is unchanged.
195 EXPECT_EQ(0ul, pm->update_error_count_); 220 EXPECT_EQ(0ul, pm->update_error_count_);
196 EXPECT_EQ(1ul, pm->update_back_off_mult_); 221 EXPECT_EQ(1ul, pm->update_back_off_mult_);
197 } 222 }
198 223
199 } // namespace safe_browsing 224 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698