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 "chrome/test/ui/javascript_test_util.h" | 5 #include "chrome/test/ui/javascript_test_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/common/json_value_serializer.h" | 12 #include "content/common/json_value_serializer.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 bool JsonDictionaryToMap(const std::string& json, | 15 bool JsonDictionaryToMap(const std::string& json, |
16 std::map<std::string, std::string>* results) { | 16 std::map<std::string, std::string>* results) { |
17 DCHECK(results != NULL); | 17 DCHECK(results != NULL); |
18 JSONStringValueSerializer deserializer(json); | 18 JSONStringValueSerializer deserializer(json); |
19 scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); | 19 scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); |
20 | 20 |
21 // Note that we don't use ASSERT_TRUE here (and in some other places) as it | 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. | 22 // doesn't work inside a function with a return type other than void. |
23 EXPECT_TRUE(root.get()); | 23 EXPECT_TRUE(root.get()); |
24 if (!root.get()) | 24 if (!root.get()) |
25 return false; | 25 return false; |
26 | 26 |
27 EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); | 27 EXPECT_TRUE(root->IsDictionary()); |
28 if (!root->IsType(Value::TYPE_DICTIONARY)) | 28 if (!root->IsDictionary()) |
29 return false; | 29 return false; |
30 | 30 |
31 DictionaryValue* dict = static_cast<DictionaryValue*>(root.get()); | 31 DictionaryValue* dict = static_cast<DictionaryValue*>(root.get()); |
32 | 32 |
33 for (DictionaryValue::key_iterator it = dict->begin_keys(); | 33 for (DictionaryValue::key_iterator it = dict->begin_keys(); |
34 it != dict->end_keys(); ++it) { | 34 it != dict->end_keys(); ++it) { |
35 Value* value = NULL; | 35 Value* value = NULL; |
36 bool succeeded = dict->GetWithoutPathExpansion(*it, &value); | 36 bool succeeded = dict->GetWithoutPathExpansion(*it, &value); |
37 | 37 |
38 EXPECT_TRUE(succeeded); | 38 EXPECT_TRUE(succeeded); |
(...skipping 19 matching lines...) Expand all Loading... |
58 return false; | 58 return false; |
59 } | 59 } |
60 | 60 |
61 EXPECT_TRUE(succeeded); | 61 EXPECT_TRUE(succeeded); |
62 if (succeeded) | 62 if (succeeded) |
63 results->insert(std::make_pair(key, result)); | 63 results->insert(std::make_pair(key, result)); |
64 } | 64 } |
65 | 65 |
66 return true; | 66 return true; |
67 } | 67 } |
OLD | NEW |