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

Side by Side Diff: components/reading_list/ios/reading_list_entry_unittest.cc

Issue 2592043002: Add title update merge logic to reading list entry (Closed)
Patch Set: Update function comment Created 3 years, 12 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 "components/reading_list/ios/reading_list_entry.h" 5 #include "components/reading_list/ios/reading_list_entry.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/ios/wait_util.h"
8 #include "base/test/simple_test_tick_clock.h" 9 #include "base/test/simple_test_tick_clock.h"
9 #include "components/reading_list/ios/proto/reading_list.pb.h" 10 #include "components/reading_list/ios/proto/reading_list.pb.h"
10 #include "components/sync/protocol/reading_list_specifics.pb.h" 11 #include "components/sync/protocol/reading_list_specifics.pb.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 const int kFirstBackoff = 10; 15 const int kFirstBackoff = 10;
15 const int kSecondBackoff = 10; 16 const int kSecondBackoff = 10;
16 const int kThirdBackoff = 60; 17 const int kThirdBackoff = 60;
17 const int kFourthBackoff = 120; 18 const int kFourthBackoff = 120;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 EXPECT_FALSE(e.HasBeenSeen()); 50 EXPECT_FALSE(e.HasBeenSeen());
50 EXPECT_FALSE(e.IsRead()); 51 EXPECT_FALSE(e.IsRead());
51 e.SetRead(false); 52 e.SetRead(false);
52 EXPECT_TRUE(e.HasBeenSeen()); 53 EXPECT_TRUE(e.HasBeenSeen());
53 EXPECT_FALSE(e.IsRead()); 54 EXPECT_FALSE(e.IsRead());
54 e.SetRead(true); 55 e.SetRead(true);
55 EXPECT_TRUE(e.HasBeenSeen()); 56 EXPECT_TRUE(e.HasBeenSeen());
56 EXPECT_TRUE(e.IsRead()); 57 EXPECT_TRUE(e.IsRead());
57 } 58 }
58 59
60 TEST(ReadingListEntry, UpdateTitle) {
61 ReadingListEntry e(GURL("http://example.com"), "bar");
62 ASSERT_EQ("bar", e.Title());
63 ASSERT_EQ(e.CreationTime(), e.UpdateTitleTime());
64
65 base::test::ios::SpinRunLoopWithMinDelay(
66 base::TimeDelta::FromMilliseconds(5));
67 e.SetTitle("foo");
68 EXPECT_GT(e.UpdateTitleTime(), e.CreationTime());
69 EXPECT_EQ("foo", e.Title());
70 }
71
59 TEST(ReadingListEntry, DistilledPathAndURL) { 72 TEST(ReadingListEntry, DistilledPathAndURL) {
60 ReadingListEntry e(GURL("http://example.com"), "bar"); 73 ReadingListEntry e(GURL("http://example.com"), "bar");
61 74
62 EXPECT_TRUE(e.DistilledPath().empty()); 75 EXPECT_TRUE(e.DistilledPath().empty());
63 76
64 const base::FilePath distilled_path("distilled/page.html"); 77 const base::FilePath distilled_path("distilled/page.html");
65 e.SetDistilledPath(distilled_path); 78 e.SetDistilledPath(distilled_path);
66 EXPECT_EQ(distilled_path, e.DistilledPath()); 79 EXPECT_EQ(distilled_path, e.DistilledPath());
67 } 80 }
68 81
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 EXPECT_EQ(local_entry.Title(), "title2"); 347 EXPECT_EQ(local_entry.Title(), "title2");
335 EXPECT_FALSE(local_entry.HasBeenSeen()); 348 EXPECT_FALSE(local_entry.HasBeenSeen());
336 EXPECT_EQ(local_entry.UpdateTime(), sync_update_time_us); 349 EXPECT_EQ(local_entry.UpdateTime(), sync_update_time_us);
337 EXPECT_EQ(local_entry.FailedDownloadCounter(), 1); 350 EXPECT_EQ(local_entry.FailedDownloadCounter(), 1);
338 EXPECT_EQ(local_entry.DistilledState(), ReadingListEntry::ERROR); 351 EXPECT_EQ(local_entry.DistilledState(), ReadingListEntry::ERROR);
339 base::Time merge_next_call = 352 base::Time merge_next_call =
340 base::Time::Now() + local_entry.TimeUntilNextTry(); 353 base::Time::Now() + local_entry.TimeUntilNextTry();
341 base::TimeDelta delta = merge_next_call - next_call; 354 base::TimeDelta delta = merge_next_call - next_call;
342 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10); 355 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10);
343 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698