OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/base/extension_js_browser_test.h" | 5 #include "chrome/test/base/extension_js_browser_test.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 base::JoinString(scripts, base::ASCIIToUTF16("\n")); | 46 base::JoinString(scripts, base::ASCIIToUTF16("\n")); |
47 std::string script = base::UTF16ToUTF8(script_16); | 47 std::string script = base::UTF16ToUTF8(script_16); |
48 | 48 |
49 std::string result = | 49 std::string result = |
50 extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 50 extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
51 Profile::FromBrowserContext(load_waiter_->browser_context()), | 51 Profile::FromBrowserContext(load_waiter_->browser_context()), |
52 load_waiter_->extension_id(), | 52 load_waiter_->extension_id(), |
53 script); | 53 script); |
54 | 54 |
55 std::unique_ptr<base::Value> value_result = base::JSONReader::Read(result); | 55 std::unique_ptr<base::Value> value_result = base::JSONReader::Read(result); |
56 CHECK_EQ(base::Value::TYPE_DICTIONARY, value_result->GetType()); | 56 CHECK_EQ(base::Value::Type::DICTIONARY, value_result->GetType()); |
57 base::DictionaryValue* dict_value = | 57 base::DictionaryValue* dict_value = |
58 static_cast<base::DictionaryValue*>(value_result.get()); | 58 static_cast<base::DictionaryValue*>(value_result.get()); |
59 bool test_result; | 59 bool test_result; |
60 std::string test_result_message; | 60 std::string test_result_message; |
61 CHECK(dict_value->GetBoolean("result", &test_result)); | 61 CHECK(dict_value->GetBoolean("result", &test_result)); |
62 CHECK(dict_value->GetString("message", &test_result_message)); | 62 CHECK(dict_value->GetString("message", &test_result_message)); |
63 if (!test_result_message.empty()) | 63 if (!test_result_message.empty()) |
64 ADD_FAILURE() << test_result_message; | 64 ADD_FAILURE() << test_result_message; |
65 return test_result; | 65 return test_result; |
66 } | 66 } |
OLD | NEW |