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

Side by Side Diff: chrome/test/ui/javascript_test_util.cc

Issue 223163003: Remove the remaining automation-based tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/ui/javascript_test_util.h ('k') | chrome/test/ui/ui_perf_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/test/ui/javascript_test_util.h"
6
7 #include "base/json/json_string_value_serializer.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 bool JsonDictionaryToMap(const std::string& json,
16 std::map<std::string, std::string>* results) {
17 DCHECK(results != NULL);
18 JSONStringValueSerializer deserializer(json);
19 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL));
20
21 // Note that we don't use ASSERT_TRUE here (and in some other places) as it
22 // doesn't work inside a function with a return type other than void.
23 EXPECT_TRUE(root.get());
24 if (!root.get())
25 return false;
26
27 EXPECT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY));
28 if (!root->IsType(base::Value::TYPE_DICTIONARY))
29 return false;
30
31 base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(root.get());
32
33 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
34 double double_result;
35 std::string result;
36 if (it.value().GetAsString(&result)) {
37 } else if (it.value().GetAsDouble(&double_result)) {
38 result = base::DoubleToString(double_result);
39 } else {
40 NOTREACHED() << "Value type not supported!";
41 return false;
42 }
43 results->insert(std::make_pair(it.key(), result));
44 }
45
46 return true;
47 }
OLDNEW
« no previous file with comments | « chrome/test/ui/javascript_test_util.h ('k') | chrome/test/ui/ui_perf_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698