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

Unified Diff: chrome/browser/ui/webui/options/preferences_browsertest.cc

Issue 11734018: Revert 174880 due to compilation error in pdf_browsertest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1374/src/
Patch Set: Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui_browsertest.cc ('k') | chrome/test/base/tracing_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/preferences_browsertest.cc
===================================================================
--- chrome/browser/ui/webui/options/preferences_browsertest.cc (revision 174946)
+++ chrome/browser/ui/webui/options/preferences_browsertest.cc (working copy)
@@ -81,85 +81,84 @@
pref_change_registrar_.Init(
PrefServiceBase::FromBrowserContext(browser()->profile()));
pref_service_ = browser()->profile()->GetPrefs();
- ASSERT_TRUE(content::ExecuteJavaScript(render_view_host_,
- "",
- "function TestEnv() {"
- " this.sentinelName_ = 'download.prompt_for_download';"
- " this.prefs_ = [];"
- " TestEnv.instance_ = this;"
- "}"
- ""
- "TestEnv.handleEvent = function(event) {"
- " var env = TestEnv.instance_;"
- " var name = event.type;"
- " env.removePrefListener_(name);"
- " if (name == TestEnv.sentinelName_)"
- " env.sentinelValue_ = event.value.value;"
- " else"
- " env.reply_[name] = event.value;"
- " if (env.fetching_ && !--env.fetching_ ||"
- " !env.fetching_ && name == env.sentinelName_) {"
- " env.removePrefListeners_();"
- " window.domAutomationController.send(JSON.stringify(env.reply_));"
- " delete env.reply_;"
- " }"
- "};"
- ""
- "TestEnv.prototype = {"
- " addPrefListener_: function(name) {"
- " Preferences.getInstance().addEventListener(name,"
- " TestEnv.handleEvent);"
- " },"
- ""
- " addPrefListeners_: function() {"
- " for (var i in this.prefs_)"
- " this.addPrefListener_(this.prefs_[i]);"
- " },"
- ""
- " removePrefListener_: function(name) {"
- " Preferences.getInstance().removeEventListener(name,"
- " TestEnv.handleEvent);"
- " },"
- ""
- " removePrefListeners_: function() {"
- " for (var i in this.prefs_)"
- " this.removePrefListener_(this.prefs_[i]);"
- " },"
- ""
- ""
- " addPref: function(name) {"
- " this.prefs_.push(name);"
- " },"
- ""
- " setupAndReply: function() {"
- " this.reply_ = {};"
- " Preferences.instance_ = new Preferences();"
- " this.addPref(this.sentinelName_);"
- " this.fetching_ = this.prefs_.length;"
- " this.addPrefListeners_();"
- " Preferences.getInstance().initialize();"
- " },"
- ""
- " runAndReply: function(test) {"
- " this.reply_ = {};"
- " this.addPrefListeners_();"
- " test();"
- " this.sentinelValue_ = !this.sentinelValue_;"
- " Preferences.setBooleanPref(this.sentinelName_, this.sentinelValue_,"
- " true);"
- " },"
- ""
- " startObserving: function() {"
- " this.reply_ = {};"
- " this.addPrefListeners_();"
- " },"
- ""
- " finishObservingAndReply: function() {"
- " this.sentinelValue_ = !this.sentinelValue_;"
- " Preferences.setBooleanPref(this.sentinelName_, this.sentinelValue_,"
- " true);"
- " }"
- "};"));
+ ASSERT_TRUE(content::ExecuteJavaScript(render_view_host_, L"",
+ L"function TestEnv() {"
+ L" this.sentinelName_ = 'download.prompt_for_download';"
+ L" this.prefs_ = [];"
+ L" TestEnv.instance_ = this;"
+ L"}"
+ L""
+ L"TestEnv.handleEvent = function(event) {"
+ L" var env = TestEnv.instance_;"
+ L" var name = event.type;"
+ L" env.removePrefListener_(name);"
+ L" if (name == TestEnv.sentinelName_)"
+ L" env.sentinelValue_ = event.value.value;"
+ L" else"
+ L" env.reply_[name] = event.value;"
+ L" if (env.fetching_ && !--env.fetching_ ||"
+ L" !env.fetching_ && name == env.sentinelName_) {"
+ L" env.removePrefListeners_();"
+ L" window.domAutomationController.send(JSON.stringify(env.reply_));"
+ L" delete env.reply_;"
+ L" }"
+ L"};"
+ L""
+ L"TestEnv.prototype = {"
+ L" addPrefListener_: function(name) {"
+ L" Preferences.getInstance().addEventListener(name,"
+ L" TestEnv.handleEvent);"
+ L" },"
+ L""
+ L" addPrefListeners_: function() {"
+ L" for (var i in this.prefs_)"
+ L" this.addPrefListener_(this.prefs_[i]);"
+ L" },"
+ L""
+ L" removePrefListener_: function(name) {"
+ L" Preferences.getInstance().removeEventListener(name,"
+ L" TestEnv.handleEvent);"
+ L" },"
+ L""
+ L" removePrefListeners_: function() {"
+ L" for (var i in this.prefs_)"
+ L" this.removePrefListener_(this.prefs_[i]);"
+ L" },"
+ L""
+ L""
+ L" addPref: function(name) {"
+ L" this.prefs_.push(name);"
+ L" },"
+ L""
+ L" setupAndReply: function() {"
+ L" this.reply_ = {};"
+ L" Preferences.instance_ = new Preferences();"
+ L" this.addPref(this.sentinelName_);"
+ L" this.fetching_ = this.prefs_.length;"
+ L" this.addPrefListeners_();"
+ L" Preferences.getInstance().initialize();"
+ L" },"
+ L""
+ L" runAndReply: function(test) {"
+ L" this.reply_ = {};"
+ L" this.addPrefListeners_();"
+ L" test();"
+ L" this.sentinelValue_ = !this.sentinelValue_;"
+ L" Preferences.setBooleanPref(this.sentinelName_, this.sentinelValue_,"
+ L" true);"
+ L" },"
+ L""
+ L" startObserving: function() {"
+ L" this.reply_ = {};"
+ L" this.addPrefListeners_();"
+ L" },"
+ L""
+ L" finishObservingAndReply: function() {"
+ L" this.sentinelValue_ = !this.sentinelValue_;"
+ L" Preferences.setBooleanPref(this.sentinelName_, this.sentinelValue_,"
+ L" true);"
+ L" }"
+ L"};"));
}
// Forwards notifications received when pref values change in the backend.
@@ -304,7 +303,7 @@
void PreferencesBrowserTest::SetupJavaScriptTestEnvironment(
const std::vector<std::string>& pref_names,
std::string* observed_json) const {
- std::stringstream javascript;
+ std::wstringstream javascript;
javascript << "var testEnv = new TestEnv();";
for (std::vector<std::string>::const_iterator name = pref_names.begin();
name != pref_names.end(); ++name)
@@ -314,7 +313,7 @@
if (!observed_json)
observed_json = &temp_observed_json;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_, "", javascript.str(), observed_json));
+ render_view_host_, L"", javascript.str(), observed_json));
}
void PreferencesBrowserTest::VerifySetPref(const std::string& name,
@@ -330,7 +329,7 @@
std::string commit_json;
base::JSONWriter::Write(value, &value_json);
base::JSONWriter::Write(commit_ptr.get(), &commit_json);
- std::stringstream javascript;
+ std::wstringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.set" << type.c_str() << "Pref("
<< " '" << name.c_str() << "',"
@@ -338,7 +337,7 @@
<< " " << commit_json.c_str() << ");});";
std::string observed_json;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_, "", javascript.str(), &observed_json));
+ render_view_host_, L"", javascript.str(), &observed_json));
VerifyObservedPref(observed_json, name, value, "", false, !commit);
VerifyAndClearExpectations();
}
@@ -353,14 +352,14 @@
scoped_ptr<base::Value> commit_ptr(new base::FundamentalValue(commit));
std::string commit_json;
base::JSONWriter::Write(commit_ptr.get(), &commit_json);
- std::stringstream javascript;
+ std::wstringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.clearPref("
<< " '" << name.c_str() << "',"
<< " " << commit_json.c_str() << ");});";
std::string observed_json;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_, "", javascript.str(), &observed_json));
+ render_view_host_, L"", javascript.str(), &observed_json));
VerifyObservedPref(observed_json, name, value, "recommended", false, !commit);
VerifyAndClearExpectations();
}
@@ -368,13 +367,13 @@
void PreferencesBrowserTest::VerifyCommit(const std::string& name,
const base::Value* value,
const std::string& controlledBy) {
- std::stringstream javascript;
+ std::wstringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.getInstance().commitPref("
<< " '" << name.c_str() << "');});";
std::string observed_json;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_, "", javascript.str(), &observed_json));
+ render_view_host_, L"", javascript.str(), &observed_json));
VerifyObservedPref(observed_json, name, value, controlledBy, false, false);
}
@@ -396,27 +395,25 @@
const base::Value* value,
const std::string& controlledBy) {
ExpectNoCommit(name);
- std::stringstream javascript;
+ std::wstringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.getInstance().rollbackPref("
<< " '" << name.c_str() << "');});";
std::string observed_json;
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_, "", javascript.str(), &observed_json));
+ render_view_host_, L"", javascript.str(), &observed_json));
VerifyObservedPref(observed_json, name, value, controlledBy, false, true);
VerifyAndClearExpectations();
}
void PreferencesBrowserTest::StartObserving() {
ASSERT_TRUE(content::ExecuteJavaScript(
- render_view_host_, "", "testEnv.startObserving();"));
+ render_view_host_, L"", L"testEnv.startObserving();"));
}
void PreferencesBrowserTest::FinishObserving(std::string* observed_json) {
ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- render_view_host_,
- "",
- "testEnv.finishObservingAndReply();",
+ render_view_host_, L"", L"testEnv.finishObservingAndReply();",
observed_json));
}
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui_browsertest.cc ('k') | chrome/test/base/tracing_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698