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

Side by Side Diff: chrome/test/base/extension_js_browser_test.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/service/service_process_prefs.cc ('k') | chrome/test/base/javascript_browser_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 load_waiter_->WaitForExtension(extension_id, load_cb); 26 load_waiter_->WaitForExtension(extension_id, load_cb);
27 } 27 }
28 28
29 bool ExtensionJSBrowserTest::RunJavascriptTestF(bool is_async, 29 bool ExtensionJSBrowserTest::RunJavascriptTestF(bool is_async,
30 const std::string& test_fixture, 30 const std::string& test_fixture,
31 const std::string& test_name) { 31 const std::string& test_name) {
32 EXPECT_TRUE(load_waiter_->browser_context()); 32 EXPECT_TRUE(load_waiter_->browser_context());
33 if (!load_waiter_->browser_context()) 33 if (!load_waiter_->browser_context())
34 return false; 34 return false;
35 ConstValueVector args; 35 ConstValueVector args;
36 args.push_back(new base::StringValue(test_fixture)); 36 args.push_back(new base::Value(test_fixture));
37 args.push_back(new base::StringValue(test_name)); 37 args.push_back(new base::Value(test_name));
38 std::vector<base::string16> scripts; 38 std::vector<base::string16> scripts;
39 if (!libs_loaded_) { 39 if (!libs_loaded_) {
40 BuildJavascriptLibraries(&scripts); 40 BuildJavascriptLibraries(&scripts);
41 libs_loaded_ = true; 41 libs_loaded_ = true;
42 } 42 }
43 scripts.push_back(BuildRunTestJSCall(is_async, "RUN_TEST_F", args)); 43 scripts.push_back(BuildRunTestJSCall(is_async, "RUN_TEST_F", args));
44 44
45 base::string16 script_16 = 45 base::string16 script_16 =
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 }
OLDNEW
« no previous file with comments | « chrome/service/service_process_prefs.cc ('k') | chrome/test/base/javascript_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698