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

Unified Diff: ios/chrome/browser/reading_list/reading_list_model_storage_unittest.mm

Issue 2369303002: Reading List create protobuf store (Closed)
Patch Set: feedback Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/reading_list/reading_list_model_storage_unittest.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_model_storage_unittest.mm b/ios/chrome/browser/reading_list/reading_list_model_storage_unittest.mm
deleted file mode 100644
index da7bbf37be07de8e46672de0beea02e331408cb6..0000000000000000000000000000000000000000
--- a/ios/chrome/browser/reading_list/reading_list_model_storage_unittest.mm
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import <Foundation/Foundation.h>
-
-#include "base/mac/scoped_nsobject.h"
-#include "ios/chrome/browser/reading_list/reading_list_model_storage_defaults.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-NSUserDefaults* FakeNonPersistentUserDefaults() {
- // Storage only uses two methods on NSUserDefaults: -setObject:forKey: and
- // -objectForKey:, a dictionary is a perfect replacement for it. If it looks
- // like a duck, swims like a duck and quacks as a duck, then it probably is a
- // duck.
- return (NSUserDefaults*)[[[NSMutableDictionary alloc] init] autorelease];
-}
-}
-
-TEST(ReadingListStorage, CheckEmpties) {
- ReadingListModelStorageDefaults storage(FakeNonPersistentUserDefaults());
-
- std::vector<ReadingListEntry> entries;
-
- entries = storage.LoadPersistentReadList();
- EXPECT_EQ(0ul, entries.size());
- entries = storage.LoadPersistentUnreadList();
- EXPECT_EQ(0ul, entries.size());
-}
-
-TEST(ReadingListStorage, SaveOneRead) {
- NSUserDefaults* defaults = FakeNonPersistentUserDefaults();
- std::vector<ReadingListEntry> entries;
- entries.push_back(
- ReadingListEntry(GURL("http://read.example.com"), "read title"));
-
- {
- ReadingListModelStorageDefaults storage(defaults);
- storage.SavePersistentReadList(entries);
- }
-
- ReadingListModelStorageDefaults storage(defaults);
-
- const std::vector<ReadingListEntry> restored_entries(
- storage.LoadPersistentReadList());
- EXPECT_EQ(1ul, restored_entries.size());
- EXPECT_EQ(GURL("http://read.example.com"), restored_entries[0].URL());
- EXPECT_EQ("read title", restored_entries[0].Title());
- EXPECT_EQ("read title", restored_entries[0].Title());
-}
-
-TEST(ReadingListStorage, SaveOneUnead) {
- NSUserDefaults* defaults = FakeNonPersistentUserDefaults();
- std::vector<ReadingListEntry> entries;
- entries.push_back(
- ReadingListEntry(GURL("http://unread.example.com"), "unread title"));
-
- {
- ReadingListModelStorageDefaults storage(defaults);
- storage.SavePersistentUnreadList(entries);
- }
-
- ReadingListModelStorageDefaults storage(defaults);
- const std::vector<ReadingListEntry> restored_entries(
- storage.LoadPersistentUnreadList());
- EXPECT_EQ(1ul, restored_entries.size());
- EXPECT_EQ(GURL("http://unread.example.com"), restored_entries[0].URL());
- EXPECT_EQ("unread title", restored_entries[0].Title());
-}
-
-TEST(ReadingListStorage, SaveOneModified) {
- NSUserDefaults* defaults = FakeNonPersistentUserDefaults();
- std::vector<ReadingListEntry> entries;
- entries.push_back(
- ReadingListEntry(GURL("http://unread.example.com"), "unread title"));
- {
- ReadingListModelStorageDefaults storage(defaults);
- entries[0].SetDistilledURL(GURL("http://distilled.example.com"));
- storage.SavePersistentUnreadList(entries);
- }
-
- ReadingListModelStorageDefaults storage(defaults);
- const std::vector<ReadingListEntry> restored_entries(
- storage.LoadPersistentUnreadList());
- EXPECT_EQ(1ul, restored_entries.size());
- EXPECT_EQ(GURL("http://unread.example.com"), restored_entries[0].URL());
- EXPECT_EQ(GURL("http://distilled.example.com"),
- restored_entries[0].DistilledURL());
- EXPECT_EQ("unread title", restored_entries[0].Title());
-}

Powered by Google App Engine
This is Rietveld 408576698