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

Side by Side Diff: chrome/browser/browsing_data/cookies_tree_model_unittest.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cookies_tree_model.h" 5 #include "chrome/browser/browsing_data/cookies_tree_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
26 #include "chrome/browser/content_settings/mock_settings_observer.h" 26 #include "chrome/browser/content_settings/mock_settings_observer.h"
27 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
28 #include "components/content_settings/core/browser/cookie_settings.h" 28 #include "components/content_settings/core/browser/cookie_settings.h"
29 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
30 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/notification_details.h" 32 #include "content/public/browser/notification_details.h"
33 #include "content/public/browser/notification_types.h" 33 #include "content/public/browser/notification_types.h"
34 #include "content/public/test/test_browser_thread_bundle.h" 34 #include "content/public/test/test_browser_thread_bundle.h"
35 #include "extensions/features/features.h"
35 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
36 #include "net/url_request/url_request_context_getter.h" 37 #include "net/url_request/url_request_context_getter.h"
37 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
38 39
39 #if defined(ENABLE_EXTENSIONS) 40 #if BUILDFLAG(ENABLE_EXTENSIONS)
40 #include "chrome/browser/extensions/extension_special_storage_policy.h" 41 #include "chrome/browser/extensions/extension_special_storage_policy.h"
41 #endif 42 #endif
42 43
43 using ::testing::_; 44 using ::testing::_;
44 using content::BrowserThread; 45 using content::BrowserThread;
45 46
46 namespace { 47 namespace {
47 48
48 class CookiesTreeModelTest : public testing::Test { 49 class CookiesTreeModelTest : public testing::Test {
49 public: 50 public:
50 ~CookiesTreeModelTest() override { 51 ~CookiesTreeModelTest() override {
51 // Avoid memory leaks. 52 // Avoid memory leaks.
52 #if defined(ENABLE_EXTENSIONS) 53 #if BUILDFLAG(ENABLE_EXTENSIONS)
53 special_storage_policy_ = nullptr; 54 special_storage_policy_ = nullptr;
54 #endif 55 #endif
55 profile_.reset(); 56 profile_.reset();
56 base::RunLoop().RunUntilIdle(); 57 base::RunLoop().RunUntilIdle();
57 } 58 }
58 59
59 void SetUp() override { 60 void SetUp() override {
60 profile_.reset(new TestingProfile()); 61 profile_.reset(new TestingProfile());
61 mock_browsing_data_cookie_helper_ = 62 mock_browsing_data_cookie_helper_ =
62 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); 63 new MockBrowsingDataCookieHelper(profile_->GetRequestContext());
(...skipping 21 matching lines...) Expand all
84 new MockBrowsingDataFlashLSOHelper(profile_.get()); 85 new MockBrowsingDataFlashLSOHelper(profile_.get());
85 mock_browsing_data_media_license_helper_ = 86 mock_browsing_data_media_license_helper_ =
86 new MockBrowsingDataMediaLicenseHelper(profile_.get()); 87 new MockBrowsingDataMediaLicenseHelper(profile_.get());
87 88
88 const char kExtensionScheme[] = "extensionscheme"; 89 const char kExtensionScheme[] = "extensionscheme";
89 scoped_refptr<content_settings::CookieSettings> cookie_settings = 90 scoped_refptr<content_settings::CookieSettings> cookie_settings =
90 new content_settings::CookieSettings( 91 new content_settings::CookieSettings(
91 HostContentSettingsMapFactory::GetForProfile(profile_.get()), 92 HostContentSettingsMapFactory::GetForProfile(profile_.get()),
92 profile_->GetPrefs(), 93 profile_->GetPrefs(),
93 kExtensionScheme); 94 kExtensionScheme);
94 #if defined(ENABLE_EXTENSIONS) 95 #if BUILDFLAG(ENABLE_EXTENSIONS)
95 special_storage_policy_ = 96 special_storage_policy_ =
96 new ExtensionSpecialStoragePolicy(cookie_settings.get()); 97 new ExtensionSpecialStoragePolicy(cookie_settings.get());
97 #endif 98 #endif
98 } 99 }
99 100
100 void TearDown() override { 101 void TearDown() override {
101 mock_browsing_data_service_worker_helper_ = nullptr; 102 mock_browsing_data_service_worker_helper_ = nullptr;
102 mock_browsing_data_cache_storage_helper_ = nullptr; 103 mock_browsing_data_cache_storage_helper_ = nullptr;
103 mock_browsing_data_channel_id_helper_ = nullptr; 104 mock_browsing_data_channel_id_helper_ = nullptr;
104 mock_browsing_data_quota_helper_ = nullptr; 105 mock_browsing_data_quota_helper_ = nullptr;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Do not call on the root. 443 // Do not call on the root.
443 void DeleteStoredObjects(CookieTreeNode* node) { 444 void DeleteStoredObjects(CookieTreeNode* node) {
444 node->DeleteStoredObjects(); 445 node->DeleteStoredObjects();
445 CookieTreeNode* parent_node = node->parent(); 446 CookieTreeNode* parent_node = node->parent();
446 DCHECK(parent_node); 447 DCHECK(parent_node);
447 parent_node->GetModel()->Remove(parent_node, node); 448 parent_node->GetModel()->Remove(parent_node, node);
448 } 449 }
449 450
450 protected: 451 protected:
451 ExtensionSpecialStoragePolicy* special_storage_policy() { 452 ExtensionSpecialStoragePolicy* special_storage_policy() {
452 #if defined(ENABLE_EXTENSIONS) 453 #if BUILDFLAG(ENABLE_EXTENSIONS)
453 return special_storage_policy_.get(); 454 return special_storage_policy_.get();
454 #else 455 #else
455 return nullptr; 456 return nullptr;
456 #endif 457 #endif
457 } 458 }
458 459
459 content::TestBrowserThreadBundle thread_bundle_; 460 content::TestBrowserThreadBundle thread_bundle_;
460 std::unique_ptr<TestingProfile> profile_; 461 std::unique_ptr<TestingProfile> profile_;
461 scoped_refptr<MockBrowsingDataCookieHelper> 462 scoped_refptr<MockBrowsingDataCookieHelper>
462 mock_browsing_data_cookie_helper_; 463 mock_browsing_data_cookie_helper_;
(...skipping 15 matching lines...) Expand all
478 mock_browsing_data_channel_id_helper_; 479 mock_browsing_data_channel_id_helper_;
479 scoped_refptr<MockBrowsingDataServiceWorkerHelper> 480 scoped_refptr<MockBrowsingDataServiceWorkerHelper>
480 mock_browsing_data_service_worker_helper_; 481 mock_browsing_data_service_worker_helper_;
481 scoped_refptr<MockBrowsingDataCacheStorageHelper> 482 scoped_refptr<MockBrowsingDataCacheStorageHelper>
482 mock_browsing_data_cache_storage_helper_; 483 mock_browsing_data_cache_storage_helper_;
483 scoped_refptr<MockBrowsingDataFlashLSOHelper> 484 scoped_refptr<MockBrowsingDataFlashLSOHelper>
484 mock_browsing_data_flash_lso_helper_; 485 mock_browsing_data_flash_lso_helper_;
485 scoped_refptr<MockBrowsingDataMediaLicenseHelper> 486 scoped_refptr<MockBrowsingDataMediaLicenseHelper>
486 mock_browsing_data_media_license_helper_; 487 mock_browsing_data_media_license_helper_;
487 488
488 #if defined(ENABLE_EXTENSIONS) 489 #if BUILDFLAG(ENABLE_EXTENSIONS)
489 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; 490 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_;
490 #endif 491 #endif
491 }; 492 };
492 493
493 TEST_F(CookiesTreeModelTest, RemoveAll) { 494 TEST_F(CookiesTreeModelTest, RemoveAll) {
494 std::unique_ptr<CookiesTreeModel> cookies_model( 495 std::unique_ptr<CookiesTreeModel> cookies_model(
495 CreateCookiesTreeModelWithInitialSample()); 496 CreateCookiesTreeModelWithInitialSample());
496 497
497 // Reset the selection of the first row. 498 // Reset the selection of the first row.
498 { 499 {
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 "http://host1:1/,http://host2:2/,http-so://foobar.host3:3/," 1859 "http://host1:1/,http://host2:2/,http-so://foobar.host3:3/,"
1859 "http-so://foobar.host4:4/,http://host4:4/", 1860 "http-so://foobar.host4:4/,http://host4:4/",
1860 GetDisplayedLocalStorages(&cookies_model)); 1861 GetDisplayedLocalStorages(&cookies_model));
1861 // Delete host4, which should delete foobar_host4:4 in addition to host4:4 1862 // Delete host4, which should delete foobar_host4:4 in addition to host4:4
1862 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(3)); 1863 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(3));
1863 EXPECT_EQ(10, cookies_model.GetRoot()->GetTotalNodeCount()); 1864 EXPECT_EQ(10, cookies_model.GetRoot()->GetTotalNodeCount());
1864 } 1865 }
1865 } 1866 }
1866 1867
1867 } // namespace 1868 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/cookies_tree_model.cc ('k') | chrome/browser/browsing_data/downloads_counter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698