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

Side by Side Diff: components/precache/core/precache_database_unittest.cc

Issue 1961153003: Add pause/resume functionality to precache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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 "components/precache/core/precache_database.h" 5 #include "components/precache/core/precache_database.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 EXPECT_THAT(histograms_.GetAllSamples("Precache.Latency.NonPrefetch"), 374 EXPECT_THAT(histograms_.GetAllSamples("Precache.Latency.NonPrefetch"),
375 ElementsAre(Bucket(0, 6), Bucket(kLatency.InMilliseconds(), 3))); 375 ElementsAre(Bucket(0, 6), Bucket(kLatency.InMilliseconds(), 3)));
376 376
377 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved"), 377 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved"),
378 ElementsAre(Bucket(kSize1, 1), Bucket(kSize3, 1))); 378 ElementsAre(Bucket(kSize1, 1), Bucket(kSize3, 1)));
379 379
380 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved.Cellular"), 380 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved.Cellular"),
381 ElementsAre(Bucket(kSize1, 1))); 381 ElementsAre(Bucket(kSize1, 1)));
382 } 382 }
383 383
384 TEST_F(PrecacheDatabaseTest, SaveAndGetUnfinishedWork) {
385 std::list<GURL> manifests1, resources1, manifests2, resources2;
386 manifests1.push_back(GURL("http://www.m1.com/"));
387 resources1.push_back(GURL("http://www.r1.com/"));
388 manifests2.push_back(GURL("http://www.m2.com/"));
389 resources2.push_back(GURL("http://www.r2.com/"));
390 scoped_refptr<UnfinishedWork> unfinished_work =
391 new UnfinishedWork(manifests1, resources1, 1, 2, 3,
392 base::TimeTicks::FromInternalValue(100));
393 scoped_refptr<UnfinishedWork> unfinished_work2 =
394 new UnfinishedWork(manifests2, resources2, 4, 5, 6,
395 base::TimeTicks::FromInternalValue(200));
396 scoped_refptr<UnfinishedWork> unfinished_work3 =
397 new UnfinishedWork(base::TimeTicks::FromInternalValue(300));
398 scoped_refptr<UnfinishedWork> unfinished_work4 =
399 new UnfinishedWork(base::TimeTicks::FromInternalValue(50));
400 precache_database_->SaveUnfinishedWork(unfinished_work);
401 precache_database_->SaveUnfinishedWork(unfinished_work2);
402 precache_database_->GetUnfinishedWork(unfinished_work3);
403 precache_database_->GetUnfinishedWork(unfinished_work4);
404 EXPECT_TRUE(unfinished_work3->manifests.empty());
405 EXPECT_TRUE(unfinished_work3->resources.empty());
406 EXPECT_EQ(unfinished_work2->total_bytes, unfinished_work3->total_bytes);
407 EXPECT_EQ(unfinished_work2->network_bytes, unfinished_work3->network_bytes);
408 EXPECT_EQ(unfinished_work2->num_manifest_urls,
409 unfinished_work3->num_manifest_urls);
410 EXPECT_EQ(unfinished_work2->start_time, unfinished_work3->start_time);
411
412 EXPECT_EQ(unfinished_work2->manifests, unfinished_work4->manifests);
413 EXPECT_EQ(unfinished_work2->resources, unfinished_work4->resources);
414 EXPECT_EQ(unfinished_work2->total_bytes, unfinished_work4->total_bytes);
415 EXPECT_EQ(unfinished_work2->network_bytes, unfinished_work4->network_bytes);
416 EXPECT_EQ(unfinished_work2->num_manifest_urls,
417 unfinished_work4->num_manifest_urls);
418 EXPECT_EQ(unfinished_work2->start_time, unfinished_work4->start_time);
419 }
420
384 } // namespace 421 } // namespace
385 422
386 } // namespace precache 423 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698