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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler_unittest.cc

Issue 65813002: mac: Prepare most test code for -Wunused-functions too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | Annotate | Revision Log
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/ui/webui/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/sync_setup_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); 90 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS));
91 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); 91 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES));
92 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); 92 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS));
93 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); 93 result.SetBoolean("themesSynced", types.Has(syncer::THEMES));
94 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); 94 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS));
95 std::string args; 95 std::string args;
96 base::JSONWriter::Write(&result, &args); 96 base::JSONWriter::Write(&result, &args);
97 return args; 97 return args;
98 } 98 }
99 99
100 void CheckInt(const DictionaryValue* dictionary,
101 const std::string& key,
102 int expected_value) {
103 int actual_value;
104 EXPECT_TRUE(dictionary->GetInteger(key, &actual_value)) <<
105 "Did not expect to find value for " << key;
106 EXPECT_EQ(actual_value, expected_value) <<
107 "Mismatch found for " << key;
108 }
109
110 // Checks whether the passed |dictionary| contains a |key| with the given 100 // Checks whether the passed |dictionary| contains a |key| with the given
111 // |expected_value|. If |omit_if_false| is true, then the value should only 101 // |expected_value|. If |omit_if_false| is true, then the value should only
112 // be present if |expected_value| is true. 102 // be present if |expected_value| is true.
113 void CheckBool(const DictionaryValue* dictionary, 103 void CheckBool(const DictionaryValue* dictionary,
114 const std::string& key, 104 const std::string& key,
115 bool expected_value, 105 bool expected_value,
116 bool omit_if_false) { 106 bool omit_if_false) {
117 if (omit_if_false && !expected_value) { 107 if (omit_if_false && !expected_value) {
118 EXPECT_FALSE(dictionary->HasKey(key)) << 108 EXPECT_FALSE(dictionary->HasKey(key)) <<
119 "Did not expect to find value for " << key; 109 "Did not expect to find value for " << key;
120 } else { 110 } else {
121 bool actual_value; 111 bool actual_value;
122 EXPECT_TRUE(dictionary->GetBoolean(key, &actual_value)) << 112 EXPECT_TRUE(dictionary->GetBoolean(key, &actual_value)) <<
123 "No value found for " << key; 113 "No value found for " << key;
124 EXPECT_EQ(actual_value, expected_value) << 114 EXPECT_EQ(actual_value, expected_value) <<
125 "Mismatch found for " << key; 115 "Mismatch found for " << key;
126 } 116 }
127 } 117 }
128 118
129 void CheckBool(const DictionaryValue* dictionary, 119 void CheckBool(const DictionaryValue* dictionary,
130 const std::string& key, 120 const std::string& key,
131 bool expected_value) { 121 bool expected_value) {
132 return CheckBool(dictionary, key, expected_value, false); 122 return CheckBool(dictionary, key, expected_value, false);
133 } 123 }
134 124
135 void CheckString(const DictionaryValue* dictionary,
136 const std::string& key,
137 const std::string& expected_value,
138 bool omit_if_empty) {
139 if (omit_if_empty && expected_value.empty()) {
140 EXPECT_FALSE(dictionary->HasKey(key)) <<
141 "Did not expect to find value for " << key;
142 } else {
143 std::string actual_value;
144 EXPECT_TRUE(dictionary->GetString(key, &actual_value)) <<
145 "No value found for " << key;
146 EXPECT_EQ(actual_value, expected_value) <<
147 "Mismatch found for " << key;
148 }
149 }
150
151 // Checks to make sure that the values stored in |dictionary| match the values 125 // Checks to make sure that the values stored in |dictionary| match the values
152 // expected by the showSyncSetupPage() JS function for a given set of data 126 // expected by the showSyncSetupPage() JS function for a given set of data
153 // types. 127 // types.
154 void CheckConfigDataTypeArguments(DictionaryValue* dictionary, 128 void CheckConfigDataTypeArguments(DictionaryValue* dictionary,
155 SyncAllDataConfig config, 129 SyncAllDataConfig config,
156 syncer::ModelTypeSet types) { 130 syncer::ModelTypeSet types) {
157 CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA); 131 CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA);
158 CheckBool(dictionary, "syncNothing", config == SYNC_NOTHING); 132 CheckBool(dictionary, "syncNothing", config == SYNC_NOTHING);
159 CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS)); 133 CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS));
160 CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL)); 134 CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL));
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1046
1073 // This should display the sync setup dialog (not login). 1047 // This should display the sync setup dialog (not login).
1074 handler_->OpenSyncSetup(); 1048 handler_->OpenSyncSetup();
1075 1049
1076 ExpectConfig(); 1050 ExpectConfig();
1077 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 1051 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1078 DictionaryValue* dictionary; 1052 DictionaryValue* dictionary;
1079 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 1053 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1080 CheckBool(dictionary, "encryptAllData", true); 1054 CheckBool(dictionary, "encryptAllData", true);
1081 } 1055 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698