OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 EXPECT_TRUE(IsAppInstalled()); | 90 EXPECT_TRUE(IsAppInstalled()); |
91 | 91 |
92 // Check that an app page returns the correct result for | 92 // Check that an app page returns the correct result for |
93 // chrome.app.getDetails(). | 93 // chrome.app.getDetails(). |
94 ui_test_utils::NavigateToURL(browser(), app_url); | 94 ui_test_utils::NavigateToURL(browser(), app_url); |
95 ASSERT_TRUE( | 95 ASSERT_TRUE( |
96 ui_test_utils::ExecuteJavaScriptAndExtractString( | 96 ui_test_utils::ExecuteJavaScriptAndExtractString( |
97 browser()->GetSelectedWebContents()->GetRenderViewHost(), | 97 browser()->GetSelectedWebContents()->GetRenderViewHost(), |
98 L"", get_app_details, &result)); | 98 L"", get_app_details, &result)); |
99 scoped_ptr<DictionaryValue> app_details( | 99 scoped_ptr<DictionaryValue> app_details( |
100 static_cast<DictionaryValue*>( | 100 static_cast<DictionaryValue*>(base::JSONReader::Read(result))); |
101 base::JSONReader::Read(result, false /* allow trailing comma */))); | |
102 // extension->manifest() does not contain the id. | 101 // extension->manifest() does not contain the id. |
103 app_details->Remove("id", NULL); | 102 app_details->Remove("id", NULL); |
104 EXPECT_TRUE(app_details.get()); | 103 EXPECT_TRUE(app_details.get()); |
105 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); | 104 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); |
106 | 105 |
107 // Try to change app.isInstalled. Should silently fail, so | 106 // Try to change app.isInstalled. Should silently fail, so |
108 // that isInstalled should have the initial value. | 107 // that isInstalled should have the initial value. |
109 ASSERT_TRUE( | 108 ASSERT_TRUE( |
110 ui_test_utils::ExecuteJavaScriptAndExtractString( | 109 ui_test_utils::ExecuteJavaScriptAndExtractString( |
111 browser()->GetSelectedWebContents()->GetRenderViewHost(), | 110 browser()->GetSelectedWebContents()->GetRenderViewHost(), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 std::wstring get_details_for_frame = | 168 std::wstring get_details_for_frame = |
170 L"window.domAutomationController.send(" | 169 L"window.domAutomationController.send(" |
171 L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; | 170 L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; |
172 std::string json; | 171 std::string json; |
173 ASSERT_TRUE( | 172 ASSERT_TRUE( |
174 ui_test_utils::ExecuteJavaScriptAndExtractString( | 173 ui_test_utils::ExecuteJavaScriptAndExtractString( |
175 browser()->GetSelectedWebContents()->GetRenderViewHost(), | 174 browser()->GetSelectedWebContents()->GetRenderViewHost(), |
176 L"", get_details_for_frame, &json)); | 175 L"", get_details_for_frame, &json)); |
177 | 176 |
178 scoped_ptr<DictionaryValue> app_details( | 177 scoped_ptr<DictionaryValue> app_details( |
179 static_cast<DictionaryValue*>( | 178 static_cast<DictionaryValue*>(base::JSONReader::Read(json))); |
180 base::JSONReader::Read(json, false /* allow trailing comma */))); | |
181 // extension->manifest() does not contain the id. | 179 // extension->manifest() does not contain the id. |
182 app_details->Remove("id", NULL); | 180 app_details->Remove("id", NULL); |
183 EXPECT_TRUE(app_details.get()); | 181 EXPECT_TRUE(app_details.get()); |
184 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); | 182 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); |
185 } | 183 } |
OLD | NEW |