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

Unified Diff: components/download/internal/model_impl_unittest.cc

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: Using OnceCallback and removed Store::Destroy Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/download/internal/model_impl_unittest.cc
diff --git a/components/download/internal/model_impl_unittest.cc b/components/download/internal/model_impl_unittest.cc
index 19a78391702979755d00f60e52e570bc48f72d65..140976ba9f6b645938509fc64133576b72f9a5f3 100644
--- a/components/download/internal/model_impl_unittest.cc
+++ b/components/download/internal/model_impl_unittest.cc
@@ -52,15 +52,13 @@ class DownloadServiceModelImplTest : public testing::Test {
TEST_F(DownloadServiceModelImplTest, SuccessfulLifecycle) {
InSequence sequence;
EXPECT_CALL(client_, OnInitialized(true)).Times(1);
- EXPECT_CALL(client_, OnDestroyed(true)).Times(1);
+ EXPECT_CALL(client_, OnDestroyed()).Times(1);
model_->Initialize();
EXPECT_TRUE(store_->init_called());
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>());
model_->Destroy();
- EXPECT_TRUE(store_->destroy_called());
- store_->TriggerDestroy(true);
}
TEST_F(DownloadServiceModelImplTest, SuccessfulInitWithEntries) {
@@ -75,8 +73,8 @@ TEST_F(DownloadServiceModelImplTest, SuccessfulInitWithEntries) {
EXPECT_TRUE(store_->init_called());
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>(entries));
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry1, model_->Get(entry1.guid)));
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry2, model_->Get(entry2.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry1, model_->Get(entry1.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry2, model_->Get(entry2.guid)));
}
TEST_F(DownloadServiceModelImplTest, BadInit) {
@@ -87,20 +85,6 @@ TEST_F(DownloadServiceModelImplTest, BadInit) {
store_->TriggerInit(false, base::MakeUnique<std::vector<Entry>>());
}
-TEST_F(DownloadServiceModelImplTest, BadDestroy) {
- InSequence sequence;
- EXPECT_CALL(client_, OnInitialized(true)).Times(1);
- EXPECT_CALL(client_, OnDestroyed(false)).Times(1);
-
- model_->Initialize();
- EXPECT_TRUE(store_->init_called());
- store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>());
-
- model_->Destroy();
- EXPECT_TRUE(store_->destroy_called());
- store_->TriggerDestroy(false);
-}
-
TEST_F(DownloadServiceModelImplTest, Add) {
Entry entry1 = test::BuildEntry(DownloadClient::TEST, base::GenerateGUID());
Entry entry2 = test::BuildEntry(DownloadClient::TEST, base::GenerateGUID());
@@ -114,15 +98,13 @@ TEST_F(DownloadServiceModelImplTest, Add) {
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>());
model_->Add(entry1);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry1, model_->Get(entry1.guid)));
- EXPECT_TRUE(
- test::SuperficialEntryCompare(&entry1, store_->LastUpdatedEntry()));
+ EXPECT_TRUE(test::CompareEntry(&entry1, model_->Get(entry1.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry1, store_->LastUpdatedEntry()));
store_->TriggerUpdate(true);
model_->Add(entry2);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry2, model_->Get(entry2.guid)));
- EXPECT_TRUE(
- test::SuperficialEntryCompare(&entry2, store_->LastUpdatedEntry()));
+ EXPECT_TRUE(test::CompareEntry(&entry2, model_->Get(entry2.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry2, store_->LastUpdatedEntry()));
store_->TriggerUpdate(false);
EXPECT_EQ(nullptr, model_->Get(entry2.guid));
@@ -150,18 +132,16 @@ TEST_F(DownloadServiceModelImplTest, Update) {
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>(entries));
model_->Update(entry2);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry2, model_->Get(entry2.guid)));
- EXPECT_TRUE(
- test::SuperficialEntryCompare(&entry2, store_->LastUpdatedEntry()));
+ EXPECT_TRUE(test::CompareEntry(&entry2, model_->Get(entry2.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry2, store_->LastUpdatedEntry()));
store_->TriggerUpdate(true);
model_->Update(entry3);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry3, model_->Get(entry3.guid)));
- EXPECT_TRUE(
- test::SuperficialEntryCompare(&entry3, store_->LastUpdatedEntry()));
+ EXPECT_TRUE(test::CompareEntry(&entry3, model_->Get(entry3.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry3, store_->LastUpdatedEntry()));
store_->TriggerUpdate(false);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry3, model_->Get(entry3.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry3, model_->Get(entry3.guid)));
}
TEST_F(DownloadServiceModelImplTest, Remove) {
@@ -201,7 +181,7 @@ TEST_F(DownloadServiceModelImplTest, Get) {
model_->Initialize();
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>(entries));
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry, model_->Get(entry.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry, model_->Get(entry.guid)));
EXPECT_EQ(nullptr, model_->Get(base::GenerateGUID()));
}
@@ -218,8 +198,7 @@ TEST_F(DownloadServiceModelImplTest, PeekEntries) {
std::vector<Entry*> expected_peek = {&entry1, &entry2};
- EXPECT_TRUE(
- test::SuperficialEntryListCompare(expected_peek, model_->PeekEntries()));
+ EXPECT_TRUE(test::CompareEntryList(expected_peek, model_->PeekEntries()));
}
TEST_F(DownloadServiceModelImplTest, TestRemoveAfterAdd) {
@@ -234,7 +213,7 @@ TEST_F(DownloadServiceModelImplTest, TestRemoveAfterAdd) {
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>());
model_->Add(entry);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry, model_->Get(entry.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry, model_->Get(entry.guid)));
model_->Remove(entry.guid);
EXPECT_EQ(nullptr, model_->Get(entry.guid));
@@ -259,10 +238,10 @@ TEST_F(DownloadServiceModelImplTest, TestRemoveAfterUpdate) {
model_->Initialize();
store_->TriggerInit(true, base::MakeUnique<std::vector<Entry>>(entries));
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry1, model_->Get(entry1.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry1, model_->Get(entry1.guid)));
model_->Update(entry2);
- EXPECT_TRUE(test::SuperficialEntryCompare(&entry2, model_->Get(entry2.guid)));
+ EXPECT_TRUE(test::CompareEntry(&entry2, model_->Get(entry2.guid)));
model_->Remove(entry2.guid);
EXPECT_EQ(nullptr, model_->Get(entry2.guid));

Powered by Google App Engine
This is Rietveld 408576698