| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/dom_distiller/core/page_features.h" | 5 #include "components/dom_distiller/core/page_features.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 for (size_t i = 0; i < input_entries->GetSize(); ++i) { | 69 for (size_t i = 0; i < input_entries->GetSize(); ++i) { |
| 70 base::DictionaryValue* core_features; | 70 base::DictionaryValue* core_features; |
| 71 ASSERT_TRUE(input_entries->GetDictionary(i, &entry)); | 71 ASSERT_TRUE(input_entries->GetDictionary(i, &entry)); |
| 72 ASSERT_TRUE(entry->GetDictionary("features", &core_features)); | 72 ASSERT_TRUE(entry->GetDictionary("features", &core_features)); |
| 73 // CalculateDerivedFeaturesFromJSON expects a base::Value of the stringified | 73 // CalculateDerivedFeaturesFromJSON expects a base::Value of the stringified |
| 74 // JSON (and not a base::Value of the JSON itself) | 74 // JSON (and not a base::Value of the JSON itself) |
| 75 std::string stringified_json; | 75 std::string stringified_json; |
| 76 ASSERT_TRUE(base::JSONWriter::Write(*core_features, &stringified_json)); | 76 ASSERT_TRUE(base::JSONWriter::Write(*core_features, &stringified_json)); |
| 77 std::unique_ptr<base::Value> stringified_value( | 77 std::unique_ptr<base::Value> stringified_value( |
| 78 new base::StringValue(stringified_json)); | 78 new base::Value(stringified_json)); |
| 79 std::vector<double> derived( | 79 std::vector<double> derived( |
| 80 CalculateDerivedFeaturesFromJSON(stringified_value.get())); | 80 CalculateDerivedFeaturesFromJSON(stringified_value.get())); |
| 81 | 81 |
| 82 ASSERT_EQ(labels.size(), derived.size()); | 82 ASSERT_EQ(labels.size(), derived.size()); |
| 83 ASSERT_TRUE(expected_output_entries->GetDictionary(i, &entry)); | 83 ASSERT_TRUE(expected_output_entries->GetDictionary(i, &entry)); |
| 84 ASSERT_TRUE(entry->GetList("features", &derived_features)); | 84 ASSERT_TRUE(entry->GetList("features", &derived_features)); |
| 85 std::string entry_url; | 85 std::string entry_url; |
| 86 ASSERT_TRUE(entry->GetString("url", &entry_url)); | 86 ASSERT_TRUE(entry->GetString("url", &entry_url)); |
| 87 for (size_t j = 0, value_index = 1; j < derived.size(); | 87 for (size_t j = 0, value_index = 1; j < derived.size(); |
| 88 ++j, value_index += 2) { | 88 ++j, value_index += 2) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 EXPECT_EQ(0, lround(derived[7])); | 185 EXPECT_EQ(0, lround(derived[7])); |
| 186 EXPECT_EQ(0, lround(derived[8])); | 186 EXPECT_EQ(0, lround(derived[8])); |
| 187 EXPECT_EQ(10, lround(derived[9])); | 187 EXPECT_EQ(10, lround(derived[9])); |
| 188 EXPECT_EQ(0, lround(derived[10])); | 188 EXPECT_EQ(0, lround(derived[10])); |
| 189 EXPECT_EQ(1, lround(derived[11])); | 189 EXPECT_EQ(1, lround(derived[11])); |
| 190 EXPECT_EQ(0, lround(derived[12])); | 190 EXPECT_EQ(0, lround(derived[12])); |
| 191 EXPECT_EQ(0, lround(derived[13])); | 191 EXPECT_EQ(0, lround(derived[13])); |
| 192 EXPECT_EQ(9, lround(derived[14])); | 192 EXPECT_EQ(9, lround(derived[14])); |
| 193 } | 193 } |
| 194 } | 194 } |
| OLD | NEW |