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

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

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: Removed Model::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
« no previous file with comments | « components/download/internal/model_impl.cc ('k') | components/download/internal/noop_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c0b3f2154915583ea5015d1eedcb3700b0d49b7b 100644
--- a/components/download/internal/model_impl_unittest.cc
+++ b/components/download/internal/model_impl_unittest.cc
@@ -52,15 +52,10 @@ 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);
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 +70,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 +82,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 +95,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 +129,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 +178,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 +195,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 +210,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 +235,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));
« no previous file with comments | « components/download/internal/model_impl.cc ('k') | components/download/internal/noop_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698