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

Unified Diff: components/ntp_snippets/ntp_snippets_database_unittest.cc

Issue 2355393002: New snippets now replace old snippets and do not merge (Closed)
Patch Set: Marc's comments + further changes to make unittests happy Created 4 years, 3 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/ntp_snippets/ntp_snippets_database_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_database_unittest.cc b/components/ntp_snippets/ntp_snippets_database_unittest.cc
index a20133bbc17d52366d2abb584784e1f88c52b183..1c7c8f86bcd10592674d41a04c20b1b32ed0a734 100644
--- a/components/ntp_snippets/ntp_snippets_database_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_database_unittest.cc
@@ -249,7 +249,7 @@ TEST_F(NTPSnippetsDatabaseTest, Delete) {
base::RunLoop().RunUntilIdle();
}
-TEST_F(NTPSnippetsDatabaseTest, DeleteSnippetAlsoDeletesImage) {
+TEST_F(NTPSnippetsDatabaseTest, DeleteSnippetDoesNotDeleteImage) {
CreateDatabase();
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(db()->IsInitialized());
@@ -278,6 +278,38 @@ TEST_F(NTPSnippetsDatabaseTest, DeleteSnippetAlsoDeletesImage) {
// Delete the snippet.
db()->DeleteSnippet(snippet->id());
+ // Make sure the image is still there.
+ EXPECT_CALL(*this, OnImageLoaded(image_data));
+ db()->LoadImage(snippet->id(),
+ base::Bind(&NTPSnippetsDatabaseTest::OnImageLoaded,
+ base::Unretained(this)));
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST_F(NTPSnippetsDatabaseTest, DeleteImage) {
+ CreateDatabase();
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(db()->IsInitialized());
+
+ std::unique_ptr<NTPSnippet> snippet = CreateTestSnippet();
+ std::string image_data("pretty image");
+
+ // Store the image.
+ db()->SaveImage(snippet->id(), image_data);
+ base::RunLoop().RunUntilIdle();
+
+ // Make sure the image is there.
+ EXPECT_CALL(*this, OnImageLoaded(image_data));
+ db()->LoadImage(snippet->id(),
+ base::Bind(&NTPSnippetsDatabaseTest::OnImageLoaded,
+ base::Unretained(this)));
+ base::RunLoop().RunUntilIdle();
+
+ Mock::VerifyAndClearExpectations(this);
+
+ // Delete the snippet.
+ db()->DeleteImage(snippet->id());
+
// Make sure the image is gone.
EXPECT_CALL(*this, OnImageLoaded(std::string()));
db()->LoadImage(snippet->id(),

Powered by Google App Engine
This is Rietveld 408576698