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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 base::Bind(&RemoveCookieTester::SetCookieCallback, | 115 base::Bind(&RemoveCookieTester::SetCookieCallback, |
114 base::Unretained(this))); | 116 base::Unretained(this))); |
115 BlockUntilNotified(); | 117 BlockUntilNotified(); |
116 } | 118 } |
117 | 119 |
118 private: | 120 private: |
119 void GetCookieCallback(const std::string& cookies) { | 121 void GetCookieCallback(const std::string& cookies) { |
120 if (cookies == "A=1") { | 122 if (cookies == "A=1") { |
121 get_cookie_success_ = true; | 123 get_cookie_success_ = true; |
122 } else { | 124 } else { |
123 EXPECT_EQ(cookies, ""); | 125 EXPECT_EQ("", cookies); |
124 get_cookie_success_ = false; | 126 get_cookie_success_ = false; |
125 } | 127 } |
126 Notify(); | 128 Notify(); |
127 } | 129 } |
128 | 130 |
129 void SetCookieCallback(bool result) { | 131 void SetCookieCallback(bool result) { |
130 ASSERT_TRUE(result); | 132 ASSERT_TRUE(result); |
131 Notify(); | 133 Notify(); |
132 } | 134 } |
133 | 135 |
(...skipping 93 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_.get())); |
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_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 275 |
269 // BrowsingDataRemover deletes itself when it completes. | 276 // BrowsingDataRemover deletes itself when it completes. |
270 remover->Remove(remove_mask); | 277 remover->Remove(remove_mask); |
271 tester->BlockUntilNotified(); | 278 tester->BlockUntilNotified(); |
272 } | 279 } |
273 | 280 |
274 TestingProfile* GetProfile() { | 281 TestingProfile* GetProfile() { |
275 return profile_.get(); | 282 return profile_.get(); |
276 } | 283 } |
277 | 284 |
| 285 base::Time GetBeginTime() { |
| 286 return called_with_details_->removal_begin; |
| 287 } |
| 288 |
| 289 int GetRemovalMask() { |
| 290 return called_with_details_->removal_mask; |
| 291 } |
| 292 |
278 quota::MockQuotaManager* GetMockManager() { | 293 quota::MockQuotaManager* GetMockManager() { |
279 if (profile_->GetQuotaManager() == NULL) { | 294 if (profile_->GetQuotaManager() == NULL) { |
280 profile_->SetQuotaManager(new quota::MockQuotaManager( | 295 profile_->SetQuotaManager(new quota::MockQuotaManager( |
281 profile_->IsOffTheRecord(), | 296 profile_->IsOffTheRecord(), |
282 profile_->GetPath(), | 297 profile_->GetPath(), |
283 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 298 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
284 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 299 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
285 profile_->GetExtensionSpecialStoragePolicy())); | 300 profile_->GetExtensionSpecialStoragePolicy())); |
286 } | 301 } |
287 return (quota::MockQuotaManager*) profile_->GetQuotaManager(); | 302 return (quota::MockQuotaManager*) profile_->GetQuotaManager(); |
288 } | 303 } |
289 | 304 |
| 305 // content::NotificationObserver implementation. |
| 306 virtual void Observe(int type, |
| 307 const content::NotificationSource& source, |
| 308 const content::NotificationDetails& details) OVERRIDE { |
| 309 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED); |
| 310 |
| 311 // We're not taking ownership of the details object, but storing a copy of |
| 312 // it locally. |
| 313 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails( |
| 314 *content::Details<BrowsingDataRemover::NotificationDetails>( |
| 315 details).ptr())); |
| 316 |
| 317 registrar_.RemoveAll(); |
| 318 } |
| 319 |
290 private: | 320 private: |
| 321 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; |
| 322 content::NotificationRegistrar registrar_; |
| 323 |
291 // message_loop_, as well as all the threads associated with it must be | 324 // 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++. | 325 // defined before profile_ to prevent explosions. Oh how I love C++. |
293 MessageLoopForUI message_loop_; | 326 MessageLoopForUI message_loop_; |
294 content::TestBrowserThread ui_thread_; | 327 content::TestBrowserThread ui_thread_; |
295 content::TestBrowserThread db_thread_; | 328 content::TestBrowserThread db_thread_; |
296 content::TestBrowserThread webkit_thread_; | 329 content::TestBrowserThread webkit_thread_; |
297 content::TestBrowserThread file_thread_; | 330 content::TestBrowserThread file_thread_; |
298 content::TestBrowserThread io_thread_; | 331 content::TestBrowserThread io_thread_; |
299 scoped_ptr<TestingProfile> profile_; | 332 scoped_ptr<TestingProfile> profile_; |
300 | 333 |
301 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); | 334 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); |
302 }; | 335 }; |
303 | 336 |
304 // Tests --------------------------------------------------------------------- | 337 // Tests --------------------------------------------------------------------- |
305 | 338 |
306 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { | 339 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { |
307 scoped_ptr<RemoveCookieTester> tester( | 340 scoped_ptr<RemoveCookieTester> tester( |
308 new RemoveCookieTester(GetProfile())); | 341 new RemoveCookieTester(GetProfile())); |
309 | 342 |
310 tester->AddCookie(); | 343 tester->AddCookie(); |
311 ASSERT_TRUE(tester->ContainsCookie()); | 344 ASSERT_TRUE(tester->ContainsCookie()); |
312 | 345 |
313 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 346 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
314 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); | 347 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); |
315 | 348 |
| 349 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
316 EXPECT_FALSE(tester->ContainsCookie()); | 350 EXPECT_FALSE(tester->ContainsCookie()); |
317 } | 351 } |
318 | 352 |
319 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 353 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
320 scoped_ptr<RemoveHistoryTester> tester( | 354 scoped_ptr<RemoveHistoryTester> tester( |
321 new RemoveHistoryTester(GetProfile())); | 355 new RemoveHistoryTester(GetProfile())); |
322 | 356 |
323 tester->AddHistory(kOrigin1, base::Time::Now()); | 357 tester->AddHistory(kOrigin1, base::Time::Now()); |
324 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 358 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
325 | 359 |
326 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 360 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
327 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); | 361 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); |
328 | 362 |
| 363 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
329 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); | 364 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); |
330 } | 365 } |
331 | 366 |
332 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { | 367 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { |
333 scoped_ptr<RemoveHistoryTester> tester( | 368 scoped_ptr<RemoveHistoryTester> tester( |
334 new RemoveHistoryTester(GetProfile())); | 369 new RemoveHistoryTester(GetProfile())); |
335 | 370 |
336 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 371 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
337 | 372 |
338 tester->AddHistory(kOrigin1, base::Time::Now()); | 373 tester->AddHistory(kOrigin1, base::Time::Now()); |
339 tester->AddHistory(kOrigin2, two_hours_ago); | 374 tester->AddHistory(kOrigin2, two_hours_ago); |
340 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 375 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
341 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 376 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
342 | 377 |
343 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 378 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
344 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); | 379 BrowsingDataRemover::REMOVE_HISTORY, tester.get()); |
345 | 380 |
| 381 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
346 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); | 382 EXPECT_FALSE(tester->HistoryContainsURL(kOrigin1)); |
347 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 383 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
348 } | 384 } |
349 | 385 |
350 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { | 386 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { |
351 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 387 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
352 new RemoveQuotaManagedDataTester()); | 388 new RemoveQuotaManagedDataTester()); |
353 | 389 |
354 tester->PopulateTestQuotaManagedData(GetMockManager()); | 390 tester->PopulateTestQuotaManagedData(GetMockManager()); |
355 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 391 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
356 BrowsingDataRemover::REMOVE_SITE_DATA & | 392 BrowsingDataRemover::REMOVE_SITE_DATA & |
357 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 393 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
358 | 394 |
| 395 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 396 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
359 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 397 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
360 quota::kStorageTypeTemporary)); | 398 quota::kStorageTypeTemporary)); |
361 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 399 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
362 quota::kStorageTypeTemporary)); | 400 quota::kStorageTypeTemporary)); |
363 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 401 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
364 quota::kStorageTypeTemporary)); | 402 quota::kStorageTypeTemporary)); |
365 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 403 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
366 quota::kStorageTypePersistent)); | 404 quota::kStorageTypePersistent)); |
367 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 405 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
368 quota::kStorageTypePersistent)); | 406 quota::kStorageTypePersistent)); |
369 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 407 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
370 quota::kStorageTypePersistent)); | 408 quota::kStorageTypePersistent)); |
371 } | 409 } |
372 | 410 |
373 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 411 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
374 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 412 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
375 new RemoveQuotaManagedDataTester()); | 413 new RemoveQuotaManagedDataTester()); |
376 | 414 |
377 tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); | 415 tester->PopulateTestQuotaManagedTemporaryData(GetMockManager()); |
378 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 416 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
379 BrowsingDataRemover::REMOVE_SITE_DATA & | 417 BrowsingDataRemover::REMOVE_SITE_DATA & |
380 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 418 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
381 | 419 |
| 420 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 421 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
382 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 422 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
383 quota::kStorageTypeTemporary)); | 423 quota::kStorageTypeTemporary)); |
384 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 424 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
385 quota::kStorageTypeTemporary)); | 425 quota::kStorageTypeTemporary)); |
386 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 426 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
387 quota::kStorageTypeTemporary)); | 427 quota::kStorageTypeTemporary)); |
388 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 428 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
389 quota::kStorageTypePersistent)); | 429 quota::kStorageTypePersistent)); |
390 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 430 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
391 quota::kStorageTypePersistent)); | 431 quota::kStorageTypePersistent)); |
392 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 432 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
393 quota::kStorageTypePersistent)); | 433 quota::kStorageTypePersistent)); |
394 } | 434 } |
395 | 435 |
396 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 436 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
397 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 437 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
398 new RemoveQuotaManagedDataTester()); | 438 new RemoveQuotaManagedDataTester()); |
399 | 439 |
400 tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); | 440 tester->PopulateTestQuotaManagedPersistentData(GetMockManager()); |
401 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 441 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
402 BrowsingDataRemover::REMOVE_SITE_DATA & | 442 BrowsingDataRemover::REMOVE_SITE_DATA & |
403 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 443 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
404 | 444 |
| 445 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 446 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
405 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 447 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
406 quota::kStorageTypeTemporary)); | 448 quota::kStorageTypeTemporary)); |
407 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 449 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
408 quota::kStorageTypeTemporary)); | 450 quota::kStorageTypeTemporary)); |
409 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 451 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
410 quota::kStorageTypeTemporary)); | 452 quota::kStorageTypeTemporary)); |
411 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 453 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
412 quota::kStorageTypePersistent)); | 454 quota::kStorageTypePersistent)); |
413 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 455 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
414 quota::kStorageTypePersistent)); | 456 quota::kStorageTypePersistent)); |
415 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 457 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
416 quota::kStorageTypePersistent)); | 458 quota::kStorageTypePersistent)); |
417 } | 459 } |
418 | 460 |
419 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 461 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
420 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 462 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
421 new RemoveQuotaManagedDataTester()); | 463 new RemoveQuotaManagedDataTester()); |
422 | 464 |
423 GetMockManager(); // Creates the QuotaManager instance. | 465 GetMockManager(); // Creates the QuotaManager instance. |
424 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 466 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
425 BrowsingDataRemover::REMOVE_SITE_DATA & | 467 BrowsingDataRemover::REMOVE_SITE_DATA & |
426 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 468 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
427 | 469 |
| 470 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 471 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
428 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 472 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
429 quota::kStorageTypeTemporary)); | 473 quota::kStorageTypeTemporary)); |
430 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 474 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
431 quota::kStorageTypeTemporary)); | 475 quota::kStorageTypeTemporary)); |
432 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 476 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
433 quota::kStorageTypeTemporary)); | 477 quota::kStorageTypeTemporary)); |
434 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 478 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
435 quota::kStorageTypePersistent)); | 479 quota::kStorageTypePersistent)); |
436 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 480 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
437 quota::kStorageTypePersistent)); | 481 quota::kStorageTypePersistent)); |
438 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 482 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
439 quota::kStorageTypePersistent)); | 483 quota::kStorageTypePersistent)); |
440 } | 484 } |
441 | 485 |
442 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 486 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
443 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 487 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
444 new RemoveQuotaManagedDataTester()); | 488 new RemoveQuotaManagedDataTester()); |
445 tester->PopulateTestQuotaManagedData(GetMockManager()); | 489 tester->PopulateTestQuotaManagedData(GetMockManager()); |
446 | 490 |
447 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 491 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
448 BrowsingDataRemover::REMOVE_SITE_DATA & | 492 BrowsingDataRemover::REMOVE_SITE_DATA & |
449 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 493 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
450 | 494 |
| 495 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 496 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
451 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 497 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
452 quota::kStorageTypeTemporary)); | 498 quota::kStorageTypeTemporary)); |
453 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 499 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
454 quota::kStorageTypeTemporary)); | 500 quota::kStorageTypeTemporary)); |
455 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 501 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
456 quota::kStorageTypeTemporary)); | 502 quota::kStorageTypeTemporary)); |
457 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 503 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
458 quota::kStorageTypePersistent)); | 504 quota::kStorageTypePersistent)); |
459 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, | 505 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, |
460 quota::kStorageTypePersistent)); | 506 quota::kStorageTypePersistent)); |
461 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 507 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
462 quota::kStorageTypePersistent)); | 508 quota::kStorageTypePersistent)); |
463 } | 509 } |
464 | 510 |
465 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 511 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
466 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 512 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
467 new RemoveQuotaManagedDataTester()); | 513 new RemoveQuotaManagedDataTester()); |
468 tester->PopulateTestQuotaManagedData(GetMockManager()); | 514 tester->PopulateTestQuotaManagedData(GetMockManager()); |
469 | 515 |
470 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 516 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
471 BrowsingDataRemover::REMOVE_SITE_DATA & | 517 BrowsingDataRemover::REMOVE_SITE_DATA & |
472 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 518 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
473 | 519 |
| 520 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 521 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
474 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 522 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
475 quota::kStorageTypeTemporary)); | 523 quota::kStorageTypeTemporary)); |
476 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 524 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
477 quota::kStorageTypeTemporary)); | 525 quota::kStorageTypeTemporary)); |
478 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 526 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
479 quota::kStorageTypeTemporary)); | 527 quota::kStorageTypeTemporary)); |
480 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 528 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
481 quota::kStorageTypePersistent)); | 529 quota::kStorageTypePersistent)); |
482 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, | 530 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, |
483 quota::kStorageTypePersistent)); | 531 quota::kStorageTypePersistent)); |
484 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, | 532 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, |
485 quota::kStorageTypePersistent)); | 533 quota::kStorageTypePersistent)); |
486 } | 534 } |
487 | 535 |
488 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 536 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
489 // Protect kOrigin1. | 537 // Protect kOrigin1. |
490 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = | 538 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = |
491 new MockExtensionSpecialStoragePolicy; | 539 new MockExtensionSpecialStoragePolicy; |
492 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 540 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
493 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); | 541 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); |
494 | 542 |
495 scoped_ptr<RemoveQuotaManagedDataTester> tester( | 543 scoped_ptr<RemoveQuotaManagedDataTester> tester( |
496 new RemoveQuotaManagedDataTester()); | 544 new RemoveQuotaManagedDataTester()); |
497 tester->PopulateTestQuotaManagedData(GetMockManager()); | 545 tester->PopulateTestQuotaManagedData(GetMockManager()); |
498 | 546 |
499 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 547 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
500 BrowsingDataRemover::REMOVE_SITE_DATA & | 548 BrowsingDataRemover::REMOVE_SITE_DATA & |
501 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); | 549 ~BrowsingDataRemover::REMOVE_LSO_DATA, tester.get()); |
502 | 550 |
| 551 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_DATA & |
| 552 ~BrowsingDataRemover::REMOVE_LSO_DATA, GetRemovalMask()); |
503 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, | 553 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, |
504 quota::kStorageTypeTemporary)); | 554 quota::kStorageTypeTemporary)); |
505 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 555 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
506 quota::kStorageTypeTemporary)); | 556 quota::kStorageTypeTemporary)); |
507 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 557 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
508 quota::kStorageTypeTemporary)); | 558 quota::kStorageTypeTemporary)); |
509 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, | 559 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, |
510 quota::kStorageTypePersistent)); | 560 quota::kStorageTypePersistent)); |
511 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, | 561 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, |
512 quota::kStorageTypePersistent)); | 562 quota::kStorageTypePersistent)); |
513 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, | 563 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, |
514 quota::kStorageTypePersistent)); | 564 quota::kStorageTypePersistent)); |
515 } | 565 } |
516 | 566 |
517 } // namespace | 567 } // namespace |
OLD | NEW |