Index: chrome/browser/extensions/chrome_app_api_browsertest.cc |
=================================================================== |
--- chrome/browser/extensions/chrome_app_api_browsertest.cc (revision 174946) |
+++ chrome/browser/extensions/chrome_app_api_browsertest.cc (working copy) |
@@ -27,41 +27,41 @@ |
class ChromeAppAPITest : public ExtensionBrowserTest { |
protected: |
- bool IsAppInstalled() { return IsAppInstalled(""); } |
- bool IsAppInstalled(const char* frame_xpath) { |
- const char kGetAppIsInstalled[] = |
- "window.domAutomationController.send(window.chrome.app.isInstalled);"; |
+ bool IsAppInstalled() { return IsAppInstalled(L""); } |
+ bool IsAppInstalled(const std::wstring& frame_xpath) { |
+ std::wstring get_app_is_installed = |
+ L"window.domAutomationController.send(window.chrome.app.isInstalled);"; |
bool result; |
CHECK( |
content::ExecuteJavaScriptAndExtractBool( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, kGetAppIsInstalled, &result)); |
+ frame_xpath, get_app_is_installed, &result)); |
return result; |
} |
- std::string InstallState() { return InstallState(""); } |
- std::string InstallState(const char* frame_xpath) { |
- const char kGetAppInstallState[] = |
- "window.chrome.app.installState(" |
- " function(s) { window.domAutomationController.send(s); });"; |
+ std::string InstallState() { return InstallState(L""); } |
+ std::string InstallState(const std::wstring& frame_xpath) { |
+ std::wstring get_app_install_state = |
+ L"window.chrome.app.installState(" |
+ L"function(s) { window.domAutomationController.send(s); });"; |
std::string result; |
CHECK( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, kGetAppInstallState, &result)); |
+ frame_xpath, get_app_install_state, &result)); |
return result; |
} |
- std::string RunningState() { return RunningState(""); } |
- std::string RunningState(const char* frame_xpath) { |
- const char kGetAppRunningState[] = |
- "window.domAutomationController.send(" |
- " window.chrome.app.runningState());"; |
+ std::string RunningState() { return RunningState(L""); } |
+ std::string RunningState(const std::wstring& frame_xpath) { |
+ std::wstring get_app_install_state = |
+ L"window.domAutomationController.send(" |
+ L"window.chrome.app.runningState());"; |
std::string result; |
CHECK( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, kGetAppRunningState, &result)); |
+ frame_xpath, get_app_install_state, &result)); |
return result; |
} |
@@ -108,16 +108,14 @@ |
EXPECT_FALSE(IsAppInstalled()); |
// Test that a non-app page returns null for chrome.app.getDetails(). |
- const char kGetAppDetails[] = |
- "window.domAutomationController.send(" |
- " JSON.stringify(window.chrome.app.getDetails()));"; |
+ std::wstring get_app_details = |
+ L"window.domAutomationController.send(" |
+ L" JSON.stringify(window.chrome.app.getDetails()));"; |
std::string result; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- "", |
- kGetAppDetails, |
- &result)); |
+ L"", get_app_details, &result)); |
EXPECT_EQ("null", result); |
// Check that an app page has chrome.app.isInstalled = true. |
@@ -130,9 +128,7 @@ |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- "", |
- kGetAppDetails, |
- &result)); |
+ L"", get_app_details, &result)); |
scoped_ptr<DictionaryValue> app_details( |
static_cast<DictionaryValue*>(base::JSONReader::Read(result))); |
// extension->manifest() does not contain the id. |
@@ -145,19 +141,19 @@ |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- "", |
- "window.domAutomationController.send(" |
- " function() {" |
- " var value = window.chrome.app.isInstalled;" |
- " window.chrome.app.isInstalled = !value;" |
- " if (window.chrome.app.isInstalled == value) {" |
- " return 'true';" |
- " } else {" |
- " return 'false';" |
- " }" |
- " }()" |
- ");", |
- &result)); |
+ L"", |
+ L"window.domAutomationController.send(" |
+ L" function() {" |
+ L" var value = window.chrome.app.isInstalled;" |
+ L" window.chrome.app.isInstalled = !value;" |
+ L" if (window.chrome.app.isInstalled == value) {" |
+ L" return 'true';" |
+ L" } else {" |
+ L" return 'false';" |
+ L" }" |
+ L" }()" |
+ L");", |
+ &result)); |
// Should not be able to alter window.chrome.app.isInstalled from javascript"; |
EXPECT_EQ("true", result); |
@@ -190,30 +186,26 @@ |
// Test that normal pages (even apps) cannot use getDetailsForFrame(). |
ui_test_utils::NavigateToURL(browser(), app_url); |
- const char kTestUnsuccessfulAccess[] = |
- "window.domAutomationController.send(window.testUnsuccessfulAccess())"; |
+ std::wstring test_unsuccessful_access = |
+ L"window.domAutomationController.send(window.testUnsuccessfulAccess())"; |
bool result = false; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractBool( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- "", |
- kTestUnsuccessfulAccess, |
- &result)); |
+ L"", test_unsuccessful_access, &result)); |
EXPECT_TRUE(result); |
// Test that checkout can use getDetailsForFrame() and that it works |
// correctly. |
ui_test_utils::NavigateToURL(browser(), checkout_url); |
- const char kGetDetailsForFrame[] = |
- "window.domAutomationController.send(" |
- " JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; |
+ std::wstring get_details_for_frame = |
+ L"window.domAutomationController.send(" |
+ L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; |
std::string json; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- "", |
- kGetDetailsForFrame, |
- &json)); |
+ L"", get_details_for_frame, &json)); |
scoped_ptr<DictionaryValue> app_details( |
static_cast<DictionaryValue*>(base::JSONReader::Read(json))); |
@@ -284,9 +276,9 @@ |
EXPECT_EQ("cannot_run", RunningState()); |
EXPECT_FALSE(IsAppInstalled()); |
- EXPECT_EQ("installed", InstallState("//html/iframe[1]")); |
- EXPECT_EQ("cannot_run", RunningState("//html/iframe[1]")); |
- EXPECT_FALSE(IsAppInstalled("//html/iframe[1]")); |
+ EXPECT_EQ("installed", InstallState(L"//html/iframe[1]")); |
+ EXPECT_EQ("cannot_run", RunningState(L"//html/iframe[1]")); |
+ EXPECT_FALSE(IsAppInstalled(L"//html/iframe[1]")); |
} |
@@ -312,7 +304,7 @@ |
// within an app. |
ui_test_utils::NavigateToURL(browser(), app_url); |
- EXPECT_EQ("not_installed", InstallState("//html/iframe[1]")); |
- EXPECT_EQ("cannot_run", RunningState("//html/iframe[1]")); |
- EXPECT_FALSE(IsAppInstalled("//html/iframe[1]")); |
+ EXPECT_EQ("not_installed", InstallState(L"//html/iframe[1]")); |
+ EXPECT_EQ("cannot_run", RunningState(L"//html/iframe[1]")); |
+ EXPECT_FALSE(IsAppInstalled(L"//html/iframe[1]")); |
} |