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

Unified Diff: webkit/appcache/appcache_host_unittest.cc

Issue 3529009: Fix http/tests/appcache/foreign-fallback.html (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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: webkit/appcache/appcache_host_unittest.cc
===================================================================
--- webkit/appcache/appcache_host_unittest.cc (revision 64524)
+++ webkit/appcache/appcache_host_unittest.cc (working copy)
@@ -164,8 +164,14 @@
mock_frontend_.last_host_id_ = -333;
mock_frontend_.last_status_ = OBSOLETE;
+ // Precondition, a cache with an entry that is not marked as foreign.
+ const int kCacheId = 22;
+ const GURL kDocumentURL("http://origin/document");
+ scoped_refptr<AppCache> cache = new AppCache(&service_, kCacheId);
+ cache->AddEntry(kDocumentURL, AppCacheEntry(AppCacheEntry::EXPLICIT));
+
AppCacheHost host(1, &mock_frontend_, &service_);
- host.MarkAsForeignEntry(GURL("http://whatever/"), 22);
+ host.MarkAsForeignEntry(kDocumentURL, kCacheId);
// We should have received an OnCacheSelected msg for kNoCacheId.
EXPECT_EQ(1, mock_frontend_.last_host_id_);
@@ -178,8 +184,43 @@
EXPECT_EQ(&mock_frontend_, host.frontend());
EXPECT_EQ(NULL, host.associated_cache());
EXPECT_FALSE(host.is_selection_pending());
+
+ // See that the entry was marked as foreign.
+ EXPECT_TRUE(cache->GetEntry(kDocumentURL)->IsForeign());
}
+TEST_F(AppCacheHostTest, ForeignFallbackEntry) {
+ // Reset our mock frontend
+ mock_frontend_.last_cache_id_ = -333;
+ mock_frontend_.last_host_id_ = -333;
+ mock_frontend_.last_status_ = OBSOLETE;
+
+ // Precondition, a cache with a fallback entry that is not marked as foreign.
+ const int kCacheId = 22;
+ const GURL kFallbackURL("http://origin/fallback_resource");
+ scoped_refptr<AppCache> cache = new AppCache(&service_, kCacheId);
+ cache->AddEntry(kFallbackURL, AppCacheEntry(AppCacheEntry::FALLBACK));
+
+ AppCacheHost host(1, &mock_frontend_, &service_);
+ host.NotifyMainResourceFallback(kFallbackURL);
+ host.MarkAsForeignEntry(GURL("http://origin/missing_document"), kCacheId);
+
+ // We should have received an OnCacheSelected msg for kNoCacheId.
+ EXPECT_EQ(1, mock_frontend_.last_host_id_);
+ EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
+ EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
+
+ // See that it respond as if there is no cache selected.
+ EXPECT_EQ(1, host.host_id());
+ EXPECT_EQ(&service_, host.service());
+ EXPECT_EQ(&mock_frontend_, host.frontend());
+ EXPECT_EQ(NULL, host.associated_cache());
+ EXPECT_FALSE(host.is_selection_pending());
kinuko 2010/11/02 07:47:23 Do we need to test all of them in both ForeignEntr
michaeln 2010/11/02 20:25:36 It does seem like some of these are redundant. How
kinuko 2010/11/03 00:25:18 sgtm!
+
+ // See that the fallback entry was marked as foreign.
+ EXPECT_TRUE(cache->GetEntry(kFallbackURL)->IsForeign());
+}
+
TEST_F(AppCacheHostTest, FailedCacheLoad) {
// Reset our mock frontend
mock_frontend_.last_cache_id_ = -333;

Powered by Google App Engine
This is Rietveld 408576698