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

Side by Side Diff: chrome/browser/extensions/api/browsing_data/browsing_data_test.cc

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: rebase and fix compilation Created 3 years, 9 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
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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/pattern.h" 10 #include "base/strings/pattern.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( 113 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult(
114 function.get(), 114 function.get(),
115 std::string("[{\"since\": 1}]"), 115 std::string("[{\"since\": 1}]"),
116 browser())); 116 browser()));
117 EXPECT_EQ(expected_mask, GetRemovalMask()); 117 EXPECT_EQ(expected_mask, GetRemovalMask());
118 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); 118 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask());
119 } 119 }
120 120
121 void SetSinceAndVerify(browsing_data::TimePeriod since_pref) { 121 void SetSinceAndVerify(browsing_data::TimePeriod since_pref) {
122 PrefService* prefs = browser()->profile()->GetPrefs(); 122 PrefService* prefs = browser()->profile()->GetPrefs();
123 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod, since_pref); 123 prefs->SetInteger(browsing_data::prefs::kDeleteTimePeriod,
124 static_cast<int>(since_pref));
124 125
125 scoped_refptr<BrowsingDataSettingsFunction> function = 126 scoped_refptr<BrowsingDataSettingsFunction> function =
126 new BrowsingDataSettingsFunction(); 127 new BrowsingDataSettingsFunction();
127 SCOPED_TRACE("settings"); 128 SCOPED_TRACE("settings");
128 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( 129 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult(
129 function.get(), std::string("[]"), browser())); 130 function.get(), std::string("[]"), browser()));
130 131
131 base::DictionaryValue* result; 132 base::DictionaryValue* result;
132 EXPECT_TRUE(result_value->GetAsDictionary(&result)); 133 EXPECT_TRUE(result_value->GetAsDictionary(&result));
133 base::DictionaryValue* options; 134 base::DictionaryValue* options;
134 EXPECT_TRUE(result->GetDictionary("options", &options)); 135 EXPECT_TRUE(result->GetDictionary("options", &options));
135 double since; 136 double since;
136 EXPECT_TRUE(options->GetDouble("since", &since)); 137 EXPECT_TRUE(options->GetDouble("since", &since));
137 138
138 double expected_since = 0; 139 double expected_since = 0;
139 if (since_pref != browsing_data::ALL_TIME) { 140 if (since_pref != browsing_data::TimePeriod::ALL_TIME) {
140 base::Time time = CalculateBeginDeleteTime(since_pref); 141 base::Time time = CalculateBeginDeleteTime(since_pref);
141 expected_since = time.ToJsTime(); 142 expected_since = time.ToJsTime();
142 } 143 }
143 // Even a synchronous function takes nonzero time, but the difference 144 // Even a synchronous function takes nonzero time, but the difference
144 // between when the function was called and now should be well under a 145 // between when the function was called and now should be well under a
145 // second, so we'll make sure the requested start time is within 10 seconds. 146 // second, so we'll make sure the requested start time is within 10 seconds.
146 // Since the smallest selectable period is an hour, that should be 147 // Since the smallest selectable period is an hour, that should be
147 // sufficient. 148 // sufficient.
148 EXPECT_LE(expected_since, since + 10.0 * 1000.0); 149 EXPECT_LE(expected_since, since + 10.0 * 1000.0);
149 } 150 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 RunAndCompareRemovalMask<BrowsingDataRemovePasswordsFunction>( 450 RunAndCompareRemovalMask<BrowsingDataRemovePasswordsFunction>(
450 BrowsingDataRemover::REMOVE_PASSWORDS); 451 BrowsingDataRemover::REMOVE_PASSWORDS);
451 RunAndCompareRemovalMask<BrowsingDataRemoveServiceWorkersFunction>( 452 RunAndCompareRemovalMask<BrowsingDataRemoveServiceWorkersFunction>(
452 BrowsingDataRemover::REMOVE_SERVICE_WORKERS); 453 BrowsingDataRemover::REMOVE_SERVICE_WORKERS);
453 RunAndCompareRemovalMask<BrowsingDataRemoveWebSQLFunction>( 454 RunAndCompareRemovalMask<BrowsingDataRemoveWebSQLFunction>(
454 BrowsingDataRemover::REMOVE_WEBSQL); 455 BrowsingDataRemover::REMOVE_WEBSQL);
455 } 456 }
456 457
457 // Test the processing of the 'delete since' preference. 458 // Test the processing of the 'delete since' preference.
458 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSince) { 459 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSince) {
459 SetSinceAndVerify(browsing_data::ALL_TIME); 460 SetSinceAndVerify(browsing_data::TimePeriod::ALL_TIME);
460 SetSinceAndVerify(browsing_data::LAST_HOUR); 461 SetSinceAndVerify(browsing_data::TimePeriod::LAST_HOUR);
461 SetSinceAndVerify(browsing_data::LAST_DAY); 462 SetSinceAndVerify(browsing_data::TimePeriod::LAST_DAY);
462 SetSinceAndVerify(browsing_data::LAST_WEEK); 463 SetSinceAndVerify(browsing_data::TimePeriod::LAST_WEEK);
463 SetSinceAndVerify(browsing_data::FOUR_WEEKS); 464 SetSinceAndVerify(browsing_data::TimePeriod::FOUR_WEEKS);
464 } 465 }
465 466
466 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionEmpty) { 467 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionEmpty) {
467 SetPrefsAndVerifySettings(0, 0, 0); 468 SetPrefsAndVerifySettings(0, 0, 0);
468 } 469 }
469 470
470 // Test straightforward settings, mapped 1:1 to data types. 471 // Test straightforward settings, mapped 1:1 to data types.
471 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSimple) { 472 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSimple) {
472 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_CACHE, 0, 473 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_CACHE, 0,
473 BrowsingDataRemover::REMOVE_CACHE); 474 BrowsingDataRemover::REMOVE_CACHE);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 ~BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA; 520 ~BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA;
520 521
521 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES | 522 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES |
522 BrowsingDataRemover::REMOVE_HISTORY | 523 BrowsingDataRemover::REMOVE_HISTORY |
523 BrowsingDataRemover::REMOVE_DOWNLOADS, 524 BrowsingDataRemover::REMOVE_DOWNLOADS,
524 UNPROTECTED_WEB, 525 UNPROTECTED_WEB,
525 site_data_no_plugins_durable_usage_external | 526 site_data_no_plugins_durable_usage_external |
526 BrowsingDataRemover::REMOVE_HISTORY | 527 BrowsingDataRemover::REMOVE_HISTORY |
527 BrowsingDataRemover::REMOVE_DOWNLOADS); 528 BrowsingDataRemover::REMOVE_DOWNLOADS);
528 } 529 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/browsing_data/browsing_data_api.cc ('k') | chrome/browser/net/sdch_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698