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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // This file contains the output from the calculation of derived features in | 31 // This file contains the output from the calculation of derived features in |
32 // the training pipeline. | 32 // the training pipeline. |
33 ASSERT_TRUE(base::ReadFileToString( | 33 ASSERT_TRUE(base::ReadFileToString( |
34 dir_source_root.AppendASCII( | 34 dir_source_root.AppendASCII( |
35 "components/test/data/dom_distiller/derived_features.json"), | 35 "components/test/data/dom_distiller/derived_features.json"), |
36 &expected_output_data)); | 36 &expected_output_data)); |
37 | 37 |
38 scoped_ptr<base::Value> input_json = base::JSONReader::Read(input_data); | 38 scoped_ptr<base::Value> input_json = base::JSONReader::Read(input_data); |
39 ASSERT_TRUE(input_json); | 39 ASSERT_TRUE(input_json); |
40 | 40 |
41 scoped_ptr<base::Value> expected_output_json( | 41 scoped_ptr<base::Value> expected_output_json = |
42 base::JSONReader::DeprecatedRead(expected_output_data)); | 42 base::JSONReader::Read(expected_output_data); |
43 ASSERT_TRUE(expected_output_json); | 43 ASSERT_TRUE(expected_output_json); |
44 | 44 |
45 base::ListValue* input_entries; | 45 base::ListValue* input_entries; |
46 ASSERT_TRUE(input_json->GetAsList(&input_entries)); | 46 ASSERT_TRUE(input_json->GetAsList(&input_entries)); |
47 ASSERT_GT(input_entries->GetSize(), 0u); | 47 ASSERT_GT(input_entries->GetSize(), 0u); |
48 | 48 |
49 base::ListValue* expected_output_entries; | 49 base::ListValue* expected_output_entries; |
50 ASSERT_TRUE(expected_output_json->GetAsList(&expected_output_entries)); | 50 ASSERT_TRUE(expected_output_json->GetAsList(&expected_output_entries)); |
51 ASSERT_EQ(expected_output_entries->GetSize(), input_entries->GetSize()); | 51 ASSERT_EQ(expected_output_entries->GetSize(), input_entries->GetSize()); |
52 | 52 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ASSERT_TRUE(derived_features->GetBoolean(value_index, &bool_value)); | 89 ASSERT_TRUE(derived_features->GetBoolean(value_index, &bool_value)); |
90 expected_value = bool_value ? 1.0 : 0.0; | 90 expected_value = bool_value ? 1.0 : 0.0; |
91 } | 91 } |
92 EXPECT_DOUBLE_EQ(derived[j], expected_value) | 92 EXPECT_DOUBLE_EQ(derived[j], expected_value) |
93 << "incorrect value for entry with url " << entry_url | 93 << "incorrect value for entry with url " << entry_url |
94 << " for derived feature " << labels[j]; | 94 << " for derived feature " << labels[j]; |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
OLD | NEW |