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

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_loader_unittest.cc

Issue 2104393002: Adds UMA for PrerenderingOffliner request processing result status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised histogram naming from OfflinerStatus to OfflinerRequestStatus Created 4 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
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 "chrome/browser/android/offline_pages/prerendering_loader.h" 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_FALSE(loader()->IsIdle()); 216 EXPECT_FALSE(loader()->IsIdle());
217 EXPECT_TRUE(loader()->IsLoaded()); 217 EXPECT_TRUE(loader()->IsLoaded());
218 EXPECT_TRUE(callback_called()); 218 EXPECT_TRUE(callback_called());
219 EXPECT_EQ(Offliner::RequestStatus::LOADED, callback_load_status()); 219 EXPECT_EQ(Offliner::RequestStatus::LOADED, callback_load_status());
220 220
221 // Consider Prerenderer stops (eg, times out) before Loader is done with it. 221 // Consider Prerenderer stops (eg, times out) before Loader is done with it.
222 test_adapter()->GetObserver()->OnPrerenderStop(); 222 test_adapter()->GetObserver()->OnPrerenderStop();
223 PumpLoop(); 223 PumpLoop();
224 EXPECT_TRUE(loader()->IsIdle()); 224 EXPECT_TRUE(loader()->IsIdle());
225 EXPECT_FALSE(loader()->IsLoaded()); 225 EXPECT_FALSE(loader()->IsLoaded());
226 EXPECT_EQ(Offliner::RequestStatus::CANCELED, callback_load_status()); 226 EXPECT_EQ(Offliner::RequestStatus::LOAD_CANCELED, callback_load_status());
227 } 227 }
228 228
229 TEST_F(PrerenderingLoaderTest, LoadPageLoadFailedNoContent) { 229 TEST_F(PrerenderingLoaderTest, LoadPageLoadFailedNoContent) {
230 test_adapter()->Configure( 230 test_adapter()->Configure(
231 nullptr /* web_contents */, 231 nullptr /* web_contents */,
232 prerender::FinalStatus::FINAL_STATUS_MEMORY_LIMIT_EXCEEDED); 232 prerender::FinalStatus::FINAL_STATUS_MEMORY_LIMIT_EXCEEDED);
233 GURL gurl("http://testit.sea"); 233 GURL gurl("http://testit.sea");
234 EXPECT_TRUE(loader()->IsIdle()); 234 EXPECT_TRUE(loader()->IsIdle());
235 EXPECT_TRUE(loader()->LoadPage( 235 EXPECT_TRUE(loader()->LoadPage(
236 gurl, 236 gurl,
237 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); 237 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this))));
238 EXPECT_FALSE(loader()->IsIdle()); 238 EXPECT_FALSE(loader()->IsIdle());
239 EXPECT_FALSE(loader()->IsLoaded()); 239 EXPECT_FALSE(loader()->IsLoaded());
240 240
241 test_adapter()->GetObserver()->OnPrerenderDomContentLoaded(); 241 test_adapter()->GetObserver()->OnPrerenderDomContentLoaded();
242 PumpLoop(); 242 PumpLoop();
243 EXPECT_TRUE(loader()->IsIdle()); 243 EXPECT_TRUE(loader()->IsIdle());
244 EXPECT_TRUE(callback_called()); 244 EXPECT_TRUE(callback_called());
245 // We did not provide any WebContents for the callback so expect did not load. 245 // We did not provide any WebContents for the callback so expect did not load.
246 EXPECT_EQ(Offliner::RequestStatus::FAILED, callback_load_status()); 246 EXPECT_EQ(Offliner::RequestStatus::LOAD_FAILED, callback_load_status());
247 247
248 // Stopped event causes no harm. 248 // Stopped event causes no harm.
249 test_adapter()->GetObserver()->OnPrerenderStop(); 249 test_adapter()->GetObserver()->OnPrerenderStop();
250 PumpLoop(); 250 PumpLoop();
251 } 251 }
252 252
253 TEST_F(PrerenderingLoaderTest, LoadPageLoadCanceledFromStopLoading) { 253 TEST_F(PrerenderingLoaderTest, LoadPageLoadCanceledFromStopLoading) {
254 GURL gurl("http://testit.sea"); 254 GURL gurl("http://testit.sea");
255 EXPECT_TRUE(loader()->IsIdle()); 255 EXPECT_TRUE(loader()->IsIdle());
256 EXPECT_TRUE(loader()->LoadPage( 256 EXPECT_TRUE(loader()->LoadPage(
257 gurl, 257 gurl,
258 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); 258 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this))));
259 EXPECT_FALSE(loader()->IsIdle()); 259 EXPECT_FALSE(loader()->IsIdle());
260 EXPECT_FALSE(loader()->IsLoaded()); 260 EXPECT_FALSE(loader()->IsLoaded());
261 261
262 loader()->StopLoading(); 262 loader()->StopLoading();
263 PumpLoop(); 263 PumpLoop();
264 EXPECT_TRUE(loader()->IsIdle()); 264 EXPECT_TRUE(loader()->IsIdle());
265 EXPECT_TRUE(callback_called()); 265 EXPECT_TRUE(callback_called());
266 EXPECT_EQ(Offliner::RequestStatus::CANCELED, callback_load_status()); 266 EXPECT_EQ(Offliner::RequestStatus::LOAD_CANCELED, callback_load_status());
267 } 267 }
268 268
269 TEST_F(PrerenderingLoaderTest, LoadPageNotAcceptedWhenNotIdle) { 269 TEST_F(PrerenderingLoaderTest, LoadPageNotAcceptedWhenNotIdle) {
270 GURL gurl("http://testit.sea"); 270 GURL gurl("http://testit.sea");
271 EXPECT_TRUE(loader()->IsIdle()); 271 EXPECT_TRUE(loader()->IsIdle());
272 EXPECT_TRUE(loader()->LoadPage( 272 EXPECT_TRUE(loader()->LoadPage(
273 gurl, 273 gurl,
274 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); 274 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this))));
275 EXPECT_FALSE(loader()->IsIdle()); 275 EXPECT_FALSE(loader()->IsIdle());
276 EXPECT_FALSE(loader()->IsLoaded()); 276 EXPECT_FALSE(loader()->IsLoaded());
277 277
278 // Now try another load while first is still active. 278 // Now try another load while first is still active.
279 EXPECT_FALSE(loader()->LoadPage( 279 EXPECT_FALSE(loader()->LoadPage(
280 gurl, 280 gurl,
281 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); 281 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this))));
282 EXPECT_FALSE(loader()->IsIdle()); 282 EXPECT_FALSE(loader()->IsIdle());
283 } 283 }
284 284
285 TEST_F(PrerenderingLoaderTest, LoadPageNotAcceptedWhenPrerenderingDisabled) { 285 TEST_F(PrerenderingLoaderTest, LoadPageNotAcceptedWhenPrerenderingDisabled) {
286 test_adapter()->Disable(); 286 test_adapter()->Disable();
287 GURL gurl("http://testit.sea"); 287 GURL gurl("http://testit.sea");
288 EXPECT_TRUE(loader()->IsIdle()); 288 EXPECT_TRUE(loader()->IsIdle());
289 EXPECT_FALSE(loader()->LoadPage( 289 EXPECT_FALSE(loader()->LoadPage(
290 gurl, 290 gurl,
291 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); 291 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this))));
292 EXPECT_TRUE(loader()->IsIdle()); 292 EXPECT_TRUE(loader()->IsIdle());
293 } 293 }
294 294
295 } // namespace offline_pages 295 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698