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

Side by Side Diff: chrome/browser/browsing_data_remover_unittest.cc

Issue 7464029: Adding QuotaManager logic to TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/testing_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data_remover.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 fileapi::kFileSystemTypePersistent)); 354 fileapi::kFileSystemTypePersistent));
355 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin2, 355 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin2,
356 fileapi::kFileSystemTypeTemporary)); 356 fileapi::kFileSystemTypeTemporary));
357 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3, 357 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3,
358 fileapi::kFileSystemTypePersistent)); 358 fileapi::kFileSystemTypePersistent));
359 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3, 359 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3,
360 fileapi::kFileSystemTypeTemporary)); 360 fileapi::kFileSystemTypeTemporary));
361 } 361 }
362 362
363 TEST_F(BrowsingDataRemoverTest, RemoveAppCacheForever) { 363 TEST_F(BrowsingDataRemoverTest, RemoveAppCacheForever) {
364 // Set up ChromeAppCacheService. 364 // Set up ChromeAppCacheService with a single protected origin
365 scoped_refptr<ChromeAppCacheService> appcache_service =
366 new ChromeAppCacheService(NULL);
367 const content::ResourceContext* resource_context = NULL;
368 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = 365 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy =
369 new MockExtensionSpecialStoragePolicy; 366 new MockExtensionSpecialStoragePolicy;
370 mock_policy->AddProtected(kProtectedManifest.GetOrigin()); 367 mock_policy->AddProtected(kProtectedManifest.GetOrigin());
371 BrowserThread::PostTask( 368 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy);
372 BrowserThread::IO, FROM_HERE, 369 scoped_refptr<ChromeAppCacheService> appcache_service =
373 NewRunnableMethod(appcache_service.get(), 370 GetProfile()->GetAppCacheService();
374 &ChromeAppCacheService::InitializeOnIOThread, 371
375 FilePath(),
376 resource_context,
377 mock_policy,
378 false));
379 MessageLoop::current()->RunAllPending();
michaeln 2011/07/22 00:09:58 the call is RunAllPending is gone now... is that o
380 TestingProfile* profile = GetProfile(); 372 TestingProfile* profile = GetProfile();
381 profile->SetAppCacheService(appcache_service);
382 profile->SetExtensionSpecialStoragePolicy(mock_policy); 373 profile->SetExtensionSpecialStoragePolicy(mock_policy);
michaeln 2011/07/22 00:09:58 since the policy is now set up on line 368, no lon
383 374
384 // Add data into the AppCacheStorage. 375 // Add data into the AppCacheStorage.
385 AppCacheInserter appcache_inserter; 376 AppCacheInserter appcache_inserter;
386 appcache_inserter.AddGroupAndCache(appcache_service, kNormalManifest); 377 appcache_inserter.AddGroupAndCache(appcache_service, kNormalManifest);
387 appcache_inserter.AddGroupAndCache(appcache_service, kProtectedManifest); 378 appcache_inserter.AddGroupAndCache(appcache_service, kProtectedManifest);
388 379
389 // Verify that adding the data succeeded. 380 // Verify that adding the data succeeded.
390 AppCacheReader reader(appcache_service); 381 AppCacheReader reader(appcache_service);
391 std::set<GURL>* origins = reader.ReadAppCaches(); 382 std::set<GURL>* origins = reader.ReadAppCaches();
392 EXPECT_EQ(2UL, origins->size()); 383 EXPECT_EQ(2UL, origins->size());
393 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end()); 384 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end());
394 EXPECT_TRUE(origins->find(kNormalManifest.GetOrigin()) != origins->end()); 385 EXPECT_TRUE(origins->find(kNormalManifest.GetOrigin()) != origins->end());
395 386
396 // Set up the object to be tested. 387 // Set up the object to be tested.
397 scoped_ptr<BrowsingDataRemoverTester> tester(new BrowsingDataRemoverTester()); 388 scoped_ptr<BrowsingDataRemoverTester> tester(new BrowsingDataRemoverTester());
398 BrowsingDataRemover* remover = new BrowsingDataRemover( 389 BrowsingDataRemover* remover = new BrowsingDataRemover(
399 profile, BrowsingDataRemover::EVERYTHING, base::Time::Now()); 390 profile, BrowsingDataRemover::EVERYTHING, base::Time::Now());
michaeln 2011/07/22 00:09:58 maybe use GetProfile() here now instead of 'profil
400 remover->AddObserver(tester.get()); 391 remover->AddObserver(tester.get());
401 392
402 // Remove the appcaches and wait for it to complete. BrowsingDataRemover 393 // Remove the appcaches and wait for it to complete. BrowsingDataRemover
403 // deletes itself when it completes. 394 // deletes itself when it completes.
404 remover->Remove(BrowsingDataRemover::REMOVE_COOKIES); 395 remover->Remove(BrowsingDataRemover::REMOVE_COOKIES);
405 tester->BlockUntilNotified(); 396 tester->BlockUntilNotified();
406 397
407 // Results: appcaches for the normal origin got deleted, appcaches for the 398 // Results: appcaches for the normal origin got deleted, appcaches for the
408 // protected origin didn't. 399 // protected origin didn't.
409 origins = reader.ReadAppCaches(); 400 origins = reader.ReadAppCaches();
410 EXPECT_EQ(1UL, origins->size()); 401 EXPECT_EQ(1UL, origins->size());
411 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end()); 402 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end());
412 } 403 }
413 404
414 } // namespace 405 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698