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

Side by Side Diff: chrome/browser/ui/cocoa/clear_browsing_data_controller_unittest.mm

Issue 5964008: Add UI to the Clear Browsing Data dialog to remove Flash LSO data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/scoped_nsobject.h" 7 #include "base/scoped_nsobject.h"
8 #include "chrome/browser/browsing_data_remover.h" 8 #include "chrome/browser/browsing_data_remover.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prefs/pref_service_mock_builder.h"
11 #include "chrome/browser/prefs/testing_pref_store.h"
10 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/cocoa/browser_test_helper.h" 14 #include "chrome/browser/ui/cocoa/browser_test_helper.h"
12 #import "chrome/browser/ui/cocoa/clear_browsing_data_controller.h" 15 #import "chrome/browser/ui/cocoa/clear_browsing_data_controller.h"
13 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
14 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/testing_browser_process.h"
15 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
17 #import "third_party/ocmock/OCMock/OCMock.h" 21 #import "third_party/ocmock/OCMock/OCMock.h"
18 22
19 namespace { 23 namespace {
20 24
21 class ClearBrowsingDataControllerTest : public CocoaTest { 25 class ClearBrowsingDataControllerTest : public CocoaTest {
22 public: 26 public:
23 virtual void SetUp() { 27 virtual void SetUp() {
24 CocoaTest::SetUp(); 28 CocoaTest::SetUp();
29
25 // Set up some interesting prefs: 30 // Set up some interesting prefs:
26 PrefService* prefs = helper_.profile()->GetPrefs(); 31 PrefService* prefs = helper_.profile()->GetPrefs();
27 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, true); 32 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, true);
28 prefs->SetBoolean(prefs::kDeleteDownloadHistory, false); 33 prefs->SetBoolean(prefs::kDeleteDownloadHistory, false);
29 prefs->SetBoolean(prefs::kDeleteCache, true); 34 prefs->SetBoolean(prefs::kDeleteCache, true);
30 prefs->SetBoolean(prefs::kDeleteCookies, false); 35 prefs->SetBoolean(prefs::kDeleteCookies, false);
31 prefs->SetBoolean(prefs::kDeletePasswords, true); 36 prefs->SetBoolean(prefs::kDeletePasswords, true);
32 prefs->SetBoolean(prefs::kDeleteFormData, false); 37 prefs->SetBoolean(prefs::kDeleteFormData, false);
38 prefs->SetBoolean(prefs::kDeleteLSOData, true);
33 prefs->SetInteger(prefs::kDeleteTimePeriod, 39 prefs->SetInteger(prefs::kDeleteTimePeriod,
34 BrowsingDataRemover::FOUR_WEEKS); 40 BrowsingDataRemover::FOUR_WEEKS);
35 controller_ = 41 controller_ =
36 [ClearBrowsingDataController controllerForProfile:helper_.profile()]; 42 [ClearBrowsingDataController controllerForProfile:helper_.profile()];
37 } 43 }
38 44
39 virtual void TearDown() { 45 virtual void TearDown() {
46 MessageLoop::current()->RunAllPending();
47
40 [controller_ closeDialog]; 48 [controller_ closeDialog];
41 CocoaTest::TearDown(); 49 CocoaTest::TearDown();
42 } 50 }
43 51
44 BrowserTestHelper helper_; 52 BrowserTestHelper helper_;
45 ClearBrowsingDataController* controller_; 53 ClearBrowsingDataController* controller_;
46 }; 54 };
47 55
48 TEST_F(ClearBrowsingDataControllerTest, InitialState) { 56 TEST_F(ClearBrowsingDataControllerTest, InitialState) {
49 // Check properties match the prefs set above: 57 // Check properties match the prefs set above:
50 EXPECT_TRUE([controller_ clearBrowsingHistory]); 58 EXPECT_TRUE([controller_ clearBrowsingHistory]);
51 EXPECT_FALSE([controller_ clearDownloadHistory]); 59 EXPECT_FALSE([controller_ clearDownloadHistory]);
52 EXPECT_TRUE([controller_ emptyCache]); 60 EXPECT_TRUE([controller_ emptyCache]);
53 EXPECT_FALSE([controller_ deleteCookies]); 61 EXPECT_FALSE([controller_ deleteCookies]);
54 EXPECT_TRUE([controller_ clearSavedPasswords]); 62 EXPECT_TRUE([controller_ clearSavedPasswords]);
55 EXPECT_FALSE([controller_ clearFormData]); 63 EXPECT_FALSE([controller_ clearFormData]);
64 EXPECT_TRUE([controller_ clearLSOData]);
56 EXPECT_EQ(BrowsingDataRemover::FOUR_WEEKS, 65 EXPECT_EQ(BrowsingDataRemover::FOUR_WEEKS,
57 [controller_ timePeriod]); 66 [controller_ timePeriod]);
58 } 67 }
59 68
69 TEST_F(ClearBrowsingDataControllerTest, ClearLSOData) {
70 PrefService* prefs = helper_.profile()->GetPrefs();
71
72 // Disable clearing LSO data.
73 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, false);
74 EXPECT_TRUE([controller_ clearLSOData]);
75 EXPECT_FALSE([controller_ clearLSODataEnabled]);
76 EXPECT_FALSE([controller_ clearLSODataChecked]);
77
78 // Enabling it again should restore the old value of the checkbox.
79 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, true);
80 EXPECT_TRUE([controller_ clearLSODataEnabled]);
81 EXPECT_TRUE([controller_ clearLSODataChecked]);
82
83 // Unchecking the checkbox should set the preference to false.
84 [controller_ setClearLSODataChecked:NO];
85 [controller_ persistToPrefs];
86 EXPECT_FALSE(prefs->GetBoolean(prefs::kDeleteLSOData));
87 }
88
60 TEST_F(ClearBrowsingDataControllerTest, InitialRemoveMask) { 89 TEST_F(ClearBrowsingDataControllerTest, InitialRemoveMask) {
61 // Check that the remove-mask matches the initial properties: 90 // Check that the remove-mask matches the initial properties:
62 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY | 91 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY |
63 BrowsingDataRemover::REMOVE_CACHE | 92 BrowsingDataRemover::REMOVE_CACHE |
64 BrowsingDataRemover::REMOVE_PASSWORDS, 93 BrowsingDataRemover::REMOVE_PASSWORDS |
94 BrowsingDataRemover::REMOVE_LSO_DATA,
65 [controller_ removeMask]); 95 [controller_ removeMask]);
66 } 96 }
67 97
68 TEST_F(ClearBrowsingDataControllerTest, ModifiedRemoveMask) { 98 TEST_F(ClearBrowsingDataControllerTest, ModifiedRemoveMask) {
69 // Invert all properties and check that the remove-mask is still correct: 99 // Invert all properties and check that the remove-mask is still correct:
70 [controller_ setClearBrowsingHistory:false]; 100 [controller_ setClearBrowsingHistory:false];
71 [controller_ setClearDownloadHistory:true]; 101 [controller_ setClearDownloadHistory:true];
72 [controller_ setEmptyCache:false]; 102 [controller_ setEmptyCache:false];
73 [controller_ setDeleteCookies:true]; 103 [controller_ setDeleteCookies:true];
74 [controller_ setClearSavedPasswords:false]; 104 [controller_ setClearSavedPasswords:false];
75 [controller_ setClearFormData:true]; 105 [controller_ setClearFormData:true];
106 [controller_ setClearLSOData:false];
76 107
77 EXPECT_EQ(BrowsingDataRemover::REMOVE_DOWNLOADS | 108 EXPECT_EQ(BrowsingDataRemover::REMOVE_DOWNLOADS |
78 BrowsingDataRemover::REMOVE_COOKIES | 109 BrowsingDataRemover::REMOVE_COOKIES |
79 BrowsingDataRemover::REMOVE_FORM_DATA, 110 BrowsingDataRemover::REMOVE_FORM_DATA,
80 [controller_ removeMask]); 111 [controller_ removeMask]);
81 } 112 }
82 113
83 TEST_F(ClearBrowsingDataControllerTest, EmptyRemoveMask) { 114 TEST_F(ClearBrowsingDataControllerTest, EmptyRemoveMask) {
84 // Clear all properties and check that the remove-mask is zero: 115 // Clear all properties and check that the remove-mask is zero:
85 [controller_ setClearBrowsingHistory:false]; 116 [controller_ setClearBrowsingHistory:false];
86 [controller_ setClearDownloadHistory:false]; 117 [controller_ setClearDownloadHistory:false];
87 [controller_ setEmptyCache:false]; 118 [controller_ setEmptyCache:false];
88 [controller_ setDeleteCookies:false]; 119 [controller_ setDeleteCookies:false];
89 [controller_ setClearSavedPasswords:false]; 120 [controller_ setClearSavedPasswords:false];
90 [controller_ setClearFormData:false]; 121 [controller_ setClearFormData:false];
122 [controller_ setClearLSOData:false];
91 123
92 EXPECT_EQ(0, 124 EXPECT_EQ(0, [controller_ removeMask]);
93 [controller_ removeMask]);
94 } 125 }
95 126
96 TEST_F(ClearBrowsingDataControllerTest, PersistToPrefs) { 127 TEST_F(ClearBrowsingDataControllerTest, PersistToPrefs) {
97 // Change some settings and store to prefs: 128 // Change some settings and store to prefs:
98 [controller_ setClearBrowsingHistory:false]; 129 [controller_ setClearBrowsingHistory:false];
99 [controller_ setClearDownloadHistory:true]; 130 [controller_ setClearDownloadHistory:true];
100 [controller_ persistToPrefs]; 131 [controller_ persistToPrefs];
101 132
102 // Test that the modified settings were stored to prefs: 133 // Test that the modified settings were stored to prefs:
103 PrefService* prefs = helper_.profile()->GetPrefs(); 134 PrefService* prefs = helper_.profile()->GetPrefs();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 object:controller 171 object:controller
141 userInfo:expectedInfo]; 172 userInfo:expectedInfo];
142 173
143 // This calls |-closeDialog| and cleans the controller up. 174 // This calls |-closeDialog| and cleans the controller up.
144 [controller dataRemoverDidFinish]; 175 [controller dataRemoverDidFinish];
145 176
146 [observer verify]; 177 [observer verify];
147 } 178 }
148 179
149 } // namespace 180 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/clear_browsing_data_controller.mm ('k') | chrome/browser/ui/views/clear_browsing_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698