OLD | NEW |
---|---|
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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" | 13 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" |
14 #include "chrome/browser/history/history.h" | 14 #include "chrome/browser/history/history.h" |
15 #include "chrome/common/chrome_notification_types.h" | |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/test/base/testing_pref_service.h" | 17 #include "chrome/test/base/testing_pref_service.h" |
17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "content/public/browser/notification_service.h" | |
18 #include "content/test/test_browser_thread.h" | 20 #include "content/test/test_browser_thread.h" |
19 #include "net/base/cookie_monster.h" | 21 #include "net/base/cookie_monster.h" |
20 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
21 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "webkit/fileapi/file_system_context.h" | 25 #include "webkit/fileapi/file_system_context.h" |
24 #include "webkit/fileapi/file_system_file_util.h" | 26 #include "webkit/fileapi/file_system_file_util.h" |
25 #include "webkit/fileapi/file_system_operation_context.h" | 27 #include "webkit/fileapi/file_system_operation_context.h" |
26 #include "webkit/fileapi/file_system_path_manager.h" | 28 #include "webkit/fileapi/file_system_path_manager.h" |
27 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 29 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 EXPECT_TRUE(manager->OriginHasData(kOrigin3, | 229 EXPECT_TRUE(manager->OriginHasData(kOrigin3, |
228 quota::kStorageTypeTemporary)); | 230 quota::kStorageTypeTemporary)); |
229 } | 231 } |
230 | 232 |
231 private: | 233 private: |
232 DISALLOW_COPY_AND_ASSIGN(RemoveQuotaManagedDataTester); | 234 DISALLOW_COPY_AND_ASSIGN(RemoveQuotaManagedDataTester); |
233 }; | 235 }; |
234 | 236 |
235 // Test Class ---------------------------------------------------------------- | 237 // Test Class ---------------------------------------------------------------- |
236 | 238 |
237 class BrowsingDataRemoverTest : public testing::Test { | 239 class BrowsingDataRemoverTest : public testing::Test, |
240 public content::NotificationObserver { | |
238 public: | 241 public: |
239 BrowsingDataRemoverTest() | 242 BrowsingDataRemoverTest() |
240 : ui_thread_(BrowserThread::UI, &message_loop_), | 243 : ui_thread_(BrowserThread::UI, &message_loop_), |
241 db_thread_(BrowserThread::DB, &message_loop_), | 244 db_thread_(BrowserThread::DB, &message_loop_), |
242 webkit_thread_(BrowserThread::WEBKIT, &message_loop_), | 245 webkit_thread_(BrowserThread::WEBKIT, &message_loop_), |
243 file_thread_(BrowserThread::FILE, &message_loop_), | 246 file_thread_(BrowserThread::FILE, &message_loop_), |
244 io_thread_(BrowserThread::IO, &message_loop_), | 247 io_thread_(BrowserThread::IO, &message_loop_), |
245 profile_(new TestingProfile()) { | 248 profile_(new TestingProfile()) { |
249 registrar_.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED, | |
250 content::Source<Profile>(profile_->GetOriginalProfile())); | |
246 } | 251 } |
247 | 252 |
248 virtual ~BrowsingDataRemoverTest() { | 253 virtual ~BrowsingDataRemoverTest() { |
249 } | 254 } |
250 | 255 |
251 void TearDown() { | 256 void TearDown() { |
252 // TestingProfile contains a WebKitContext. WebKitContext's destructor | 257 // TestingProfile contains a WebKitContext. WebKitContext's destructor |
253 // posts a message to the WEBKIT thread to delete some of its member | 258 // posts a message to the WEBKIT thread to delete some of its member |
254 // variables. We need to ensure that the profile is destroyed, and that | 259 // variables. We need to ensure that the profile is destroyed, and that |
255 // the message loop is cleared out, before destroying the threads and loop. | 260 // the message loop is cleared out, before destroying the threads and loop. |
256 // Otherwise we leak memory. | 261 // Otherwise we leak memory. |
257 profile_.reset(); | 262 profile_.reset(); |
258 message_loop_.RunAllPending(); | 263 message_loop_.RunAllPending(); |
259 } | 264 } |
260 | 265 |
261 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, | 266 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, |
262 int remove_mask, | 267 int remove_mask, |
263 BrowsingDataRemoverTester* tester) { | 268 BrowsingDataRemoverTester* tester) { |
264 BrowsingDataRemover* remover = new BrowsingDataRemover( | 269 BrowsingDataRemover* remover = new BrowsingDataRemover( |
265 profile_.get(), period, | 270 profile_.get(), period, |
266 base::Time::Now() + base::TimeDelta::FromMilliseconds(10)); | 271 base::Time::Now() + base::TimeDelta::FromMilliseconds(10)); |
267 remover->AddObserver(tester); | 272 remover->AddObserver(tester); |
268 | 273 |
274 called_with_mask_ = 0; | |
275 called_with_time_ = base::Time(); | |
276 | |
269 // BrowsingDataRemover deletes itself when it completes. | 277 // BrowsingDataRemover deletes itself when it completes. |
270 remover->Remove(remove_mask); | 278 remover->Remove(remove_mask); |
271 tester->BlockUntilNotified(); | 279 tester->BlockUntilNotified(); |
272 } | 280 } |
273 | 281 |
274 TestingProfile* GetProfile() { | 282 TestingProfile* GetProfile() { |
275 return profile_.get(); | 283 return profile_.get(); |
276 } | 284 } |
277 | 285 |
286 base::Time GetBeginTime() { | |
287 return called_with_time_; | |
288 } | |
289 | |
290 int GetRemovalMask() { | |
291 return called_with_mask_; | |
292 } | |
293 | |
278 quota::MockQuotaManager* GetMockManager() { | 294 quota::MockQuotaManager* GetMockManager() { |
279 if (profile_->GetQuotaManager() == NULL) { | 295 if (profile_->GetQuotaManager() == NULL) { |
280 profile_->SetQuotaManager(new quota::MockQuotaManager( | 296 profile_->SetQuotaManager(new quota::MockQuotaManager( |
281 profile_->IsOffTheRecord(), | 297 profile_->IsOffTheRecord(), |
282 profile_->GetPath(), | 298 profile_->GetPath(), |
283 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 299 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
284 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 300 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
285 profile_->GetExtensionSpecialStoragePolicy())); | 301 profile_->GetExtensionSpecialStoragePolicy())); |
286 } | 302 } |
287 return (quota::MockQuotaManager*) profile_->GetQuotaManager(); | 303 return (quota::MockQuotaManager*) profile_->GetQuotaManager(); |
288 } | 304 } |
289 | 305 |
306 // content::NotificationObserver implementation. | |
307 virtual void Observe(int type, | |
308 const content::NotificationSource& source, | |
309 const content::NotificationDetails& details) OVERRIDE { | |
310 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED); | |
311 | |
312 // We're not taking ownership of the details object, but simply storing | |
313 // copies of its contents. | |
314 BrowsingDataRemover::NotificationDetail* remover_detail( | |
315 content::Details<BrowsingDataRemover::NotificationDetail>( | |
316 details).ptr()); | |
317 called_with_time_ = remover_detail->removal_begin; | |
318 called_with_mask_ = remover_detail->removal_mask; | |
319 | |
320 registrar_.RemoveAll(); | |
321 } | |
322 | |
290 private: | 323 private: |
324 base::Time called_with_time_; | |
jochen (gone - plz use gerrit)
2011/12/13 13:18:48
what about just storing a NotificationDetails obje
Mike West
2011/12/13 14:23:26
Done, though I'm not convinced it's any prettier.
| |
325 int called_with_mask_; | |
326 content::NotificationRegistrar registrar_; | |
327 | |
291 // message_loop_, as well as all the threads associated with it must be | 328 // message_loop_, as well as all the threads associated with it must be |
292 // defined before profile_ to prevent explosions. Oh how I love C++. | 329 // defined before profile_ to prevent explosions. Oh how I love C++. |
293 MessageLoopForUI message_loop_; | 330 MessageLoopForUI message_loop_; |
294 content::TestBrowserThread ui_thread_; | 331 content::TestBrowserThread ui_thread_; |
295 content::TestBrowserThread db_thread_; | 332 content::TestBrowserThread db_thread_; |
296 content::TestBrowserThread webkit_thread_; | 333 content::TestBrowserThread webkit_thread_; |
297 content::TestBrowserThread file_thread_; | 334 content::TestBrowserThread file_thread_; |
298 content::TestBrowserThread io_thread_; | 335 content::TestBrowserThread io_thread_; |
299 scoped_ptr<TestingProfile> profile_; | 336 scoped_ptr<TestingProfile> profile_; |
300 | 337 |
301 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); | 338 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); |
302 }; | 339 }; |
303 | 340 |
304 // Tests --------------------------------------------------------------------- | 341 // Tests --------------------------------------------------------------------- |
305 | 342 |
306 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { | 343 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { |
307 scoped_ptr<RemoveCookieTester> tester( | 344 scoped_ptr<RemoveCookieTester> tester( |
308 new RemoveCookieTester(GetProfile())); | 345 new RemoveCookieTester(GetProfile())); |
309 | 346 |
310 tester->AddCookie(); | 347 tester->AddCookie(); |
311 ASSERT_TRUE(tester->ContainsCookie()); | 348 ASSERT_TRUE(tester->ContainsCookie()); |
312 | 349 |
313 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 350 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
314 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); | 351 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); |
315 | 352 |
353 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_COOKIES); | |
jochen (gone - plz use gerrit)
2011/12/13 13:18:48
EXPECT_EQ takes expected, actual as parameters IIR
Mike West
2011/12/13 14:23:26
Needle, haystack. Haystack, needle. What... you me
| |
316 EXPECT_FALSE(tester->ContainsCookie()); | 354 EXPECT_FALSE(tester->ContainsCookie()); |
317 } | 355 } |
318 | 356 |
319 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 357 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
320 scoped_ptr<RemoveHistoryTester> tester( | 358 scoped_ptr<RemoveHistoryTester> tester( |
321 new RemoveHistoryTester(GetProfile())); | 359 new RemoveHistoryTester(GetProfile())); |
322 | 360 |
323 tester->AddHistory(kOrigin1, base::Time::Now()); | 361 tester->AddHistory(kOrigin1, base::Time::Now()); |
324 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 362 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
325 | 363 |
326 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 364 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
327 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); | 365 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); |
328 | 366 |
367 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_HISTORY); | |
329 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); | 368 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); |
330 } | 369 } |
331 | 370 |
332 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { | 371 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { |
333 scoped_ptr<RemoveHistoryTester> tester( | 372 scoped_ptr<RemoveHistoryTester> tester( |
334 new RemoveHistoryTester(GetProfile())); | 373 new RemoveHistoryTester(GetProfile())); |
335 | 374 |
336 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 375 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
337 | 376 |
338 tester->AddHistory(kOrigin1, base::Time::Now()); | 377 tester->AddHistory(kOrigin1, base::Time::Now()); |
339 tester->AddHistory(kOrigin2, two_hours_ago); | 378 tester->AddHistory(kOrigin2, two_hours_ago); |
340 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 379 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
341 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 380 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
342 | 381 |
343 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 382 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
344 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); | 383 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); |
345 | 384 |
385 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_HISTORY); | |
346 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); | 386 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); |
347 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 387 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
348 } | 388 } |
349 | 389 |
350 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { | 390 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { |
351 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 391 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
352 new RemoveQuotaManagedDataTester()); | 392 new RemoveQuotaManagedDataTester()); |
353 | 393 |
354 tester->PopulateTestQuotaManagedData(GetMockManager()); | 394 tester->PopulateTestQuotaManagedData(GetMockManager()); |
355 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 395 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
356 BrowsingDataRemover::REMOVE_SITE_DATA & | 396 BrowsingDataRemover::REMOVE_SITE_DATA & |
357 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 397 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
358 | 398 |
399 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
400 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
359 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 401 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
360 quota::kStorageTypeTemporary)); | 402 quota::kStorageTypeTemporary)); |
361 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 403 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
362 quota::kStorageTypeTemporary)); | 404 quota::kStorageTypeTemporary)); |
363 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 405 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
364 quota::kStorageTypeTemporary)); | 406 quota::kStorageTypeTemporary)); |
365 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 407 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
366 quota::kStorageTypePersistent)); | 408 quota::kStorageTypePersistent)); |
367 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 409 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
368 quota::kStorageTypePersistent)); | 410 quota::kStorageTypePersistent)); |
369 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 411 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
370 quota::kStorageTypePersistent)); | 412 quota::kStorageTypePersistent)); |
371 } | 413 } |
372 | 414 |
373 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 415 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
374 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 416 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
375 new RemoveQuotaManagedDataTester()); | 417 new RemoveQuotaManagedDataTester()); |
376 | 418 |
377 tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); | 419 tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); |
378 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 420 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
379 BrowsingDataRemover::REMOVE_SITE_DATA & | 421 BrowsingDataRemover::REMOVE_SITE_DATA & |
380 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 422 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
381 | 423 |
424 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
425 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
382 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 426 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
383 quota::kStorageTypeTemporary)); | 427 quota::kStorageTypeTemporary)); |
384 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 428 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
385 quota::kStorageTypeTemporary)); | 429 quota::kStorageTypeTemporary)); |
386 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 430 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
387 quota::kStorageTypeTemporary)); | 431 quota::kStorageTypeTemporary)); |
388 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 432 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
389 quota::kStorageTypePersistent)); | 433 quota::kStorageTypePersistent)); |
390 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 434 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
391 quota::kStorageTypePersistent)); | 435 quota::kStorageTypePersistent)); |
392 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 436 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
393 quota::kStorageTypePersistent)); | 437 quota::kStorageTypePersistent)); |
394 } | 438 } |
395 | 439 |
396 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 440 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
397 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 441 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
398 new RemoveQuotaManagedDataTester()); | 442 new RemoveQuotaManagedDataTester()); |
399 | 443 |
400 tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); | 444 tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); |
401 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 445 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
402 BrowsingDataRemover::REMOVE_SITE_DATA & | 446 BrowsingDataRemover::REMOVE_SITE_DATA & |
403 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 447 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
404 | 448 |
449 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
450 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
405 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 451 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
406 quota::kStorageTypeTemporary)); | 452 quota::kStorageTypeTemporary)); |
407 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 453 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
408 quota::kStorageTypeTemporary)); | 454 quota::kStorageTypeTemporary)); |
409 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 455 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
410 quota::kStorageTypeTemporary)); | 456 quota::kStorageTypeTemporary)); |
411 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 457 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
412 quota::kStorageTypePersistent)); | 458 quota::kStorageTypePersistent)); |
413 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 459 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
414 quota::kStorageTypePersistent)); | 460 quota::kStorageTypePersistent)); |
415 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 461 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
416 quota::kStorageTypePersistent)); | 462 quota::kStorageTypePersistent)); |
417 } | 463 } |
418 | 464 |
419 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 465 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
420 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 466 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
421 new RemoveQuotaManagedDataTester()); | 467 new RemoveQuotaManagedDataTester()); |
422 | 468 |
423 GetMockManager(); // Creates the QuotaManager instance. | 469 GetMockManager(); // Creates the QuotaManager instance. |
424 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 470 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
425 BrowsingDataRemover::REMOVE_SITE_DATA & | 471 BrowsingDataRemover::REMOVE_SITE_DATA & |
426 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 472 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
427 | 473 |
474 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
475 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
428 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 476 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
429 quota::kStorageTypeTemporary)); | 477 quota::kStorageTypeTemporary)); |
430 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 478 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
431 quota::kStorageTypeTemporary)); | 479 quota::kStorageTypeTemporary)); |
432 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 480 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
433 quota::kStorageTypeTemporary)); | 481 quota::kStorageTypeTemporary)); |
434 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 482 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
435 quota::kStorageTypePersistent)); | 483 quota::kStorageTypePersistent)); |
436 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 484 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
437 quota::kStorageTypePersistent)); | 485 quota::kStorageTypePersistent)); |
438 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 486 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
439 quota::kStorageTypePersistent)); | 487 quota::kStorageTypePersistent)); |
440 } | 488 } |
441 | 489 |
442 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 490 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
443 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 491 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
444 new RemoveQuotaManagedDataTester()); | 492 new RemoveQuotaManagedDataTester()); |
445 tester->PopulateTestQuotaManagedData(GetMockManager()); | 493 tester->PopulateTestQuotaManagedData(GetMockManager()); |
446 | 494 |
447 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 495 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
448 BrowsingDataRemover::REMOVE_SITE_DATA & | 496 BrowsingDataRemover::REMOVE_SITE_DATA & |
449 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 497 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
450 | 498 |
499 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
500 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
451 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 501 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
452 quota::kStorageTypeTemporary)); | 502 quota::kStorageTypeTemporary)); |
453 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 503 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
454 quota::kStorageTypeTemporary)); | 504 quota::kStorageTypeTemporary)); |
455 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 505 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
456 quota::kStorageTypeTemporary)); | 506 quota::kStorageTypeTemporary)); |
457 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 507 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
458 quota::kStorageTypePersistent)); | 508 quota::kStorageTypePersistent)); |
459 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, | 509 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, |
460 quota::kStorageTypePersistent)); | 510 quota::kStorageTypePersistent)); |
461 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 511 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
462 quota::kStorageTypePersistent)); | 512 quota::kStorageTypePersistent)); |
463 } | 513 } |
464 | 514 |
465 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 515 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
466 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 516 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
467 new RemoveQuotaManagedDataTester()); | 517 new RemoveQuotaManagedDataTester()); |
468 tester->PopulateTestQuotaManagedData(GetMockManager()); | 518 tester->PopulateTestQuotaManagedData(GetMockManager()); |
469 | 519 |
470 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 520 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
471 BrowsingDataRemover::REMOVE_SITE_DATA & | 521 BrowsingDataRemover::REMOVE_SITE_DATA & |
472 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 522 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
473 | 523 |
524 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
525 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
474 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 526 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
475 quota::kStorageTypeTemporary)); | 527 quota::kStorageTypeTemporary)); |
476 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 528 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
477 quota::kStorageTypeTemporary)); | 529 quota::kStorageTypeTemporary)); |
478 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 530 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
479 quota::kStorageTypeTemporary)); | 531 quota::kStorageTypeTemporary)); |
480 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 532 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
481 quota::kStorageTypePersistent)); | 533 quota::kStorageTypePersistent)); |
482 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, | 534 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, |
483 quota::kStorageTypePersistent)); | 535 quota::kStorageTypePersistent)); |
484 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 536 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
485 quota::kStorageTypePersistent)); | 537 quota::kStorageTypePersistent)); |
486 } | 538 } |
487 | 539 |
488 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 540 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
489 // Protect kOrigin1. | 541 // Protect kOrigin1. |
490 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = | 542 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = |
491 new MockExtensionSpecialStoragePolicy; | 543 new MockExtensionSpecialStoragePolicy; |
492 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 544 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
493 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); | 545 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); |
494 | 546 |
495 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 547 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
496 new RemoveQuotaManagedDataTester()); | 548 new RemoveQuotaManagedDataTester()); |
497 tester->PopulateTestQuotaManagedData(GetMockManager()); | 549 tester->PopulateTestQuotaManagedData(GetMockManager()); |
498 | 550 |
499 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 551 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
500 BrowsingDataRemover::REMOVE_SITE_DATA & | 552 BrowsingDataRemover::REMOVE_SITE_DATA & |
501 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 553 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
502 | 554 |
555 EXPECT_EQ(GetRemovalMask(), BrowsingDataRemover::REMOVE_SITE_DATA & | |
556 ~BrowsingDataRemover::REMOVE_LSO_DATA); | |
503 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, | 557 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, |
504 quota::kStorageTypeTemporary)); | 558 quota::kStorageTypeTemporary)); |
505 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 559 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
506 quota::kStorageTypeTemporary)); | 560 quota::kStorageTypeTemporary)); |
507 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 561 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
508 quota::kStorageTypeTemporary)); | 562 quota::kStorageTypeTemporary)); |
509 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 563 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
510 quota::kStorageTypePersistent)); | 564 quota::kStorageTypePersistent)); |
511 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 565 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
512 quota::kStorageTypePersistent)); | 566 quota::kStorageTypePersistent)); |
513 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 567 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
514 quota::kStorageTypePersistent)); | 568 quota::kStorageTypePersistent)); |
515 } | 569 } |
516 | 570 |
517 } // namespace | 571 } // namespace |
OLD | NEW |