| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/autofill/core/browser/legal_message_line.h" | 5 #include "components/autofill/core/browser/legal_message_line.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace autofill { | 17 namespace autofill { |
| 18 | 18 |
| 19 using Link = LegalMessageLine::Link; | 19 using Link = LegalMessageLine::Link; |
| 20 | 20 |
| 21 // A legal message line that allows for modifications. | 21 // A legal message line that allows for modifications. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 class LegalMessageLineTest : public ::testing::TestWithParam<TestCase> { | 97 class LegalMessageLineTest : public ::testing::TestWithParam<TestCase> { |
| 98 public: | 98 public: |
| 99 LegalMessageLineTest() {} | 99 LegalMessageLineTest() {} |
| 100 ~LegalMessageLineTest() override {} | 100 ~LegalMessageLineTest() override {} |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // Verifies that legal message parsing is correct. | 103 // Verifies that legal message parsing is correct. |
| 104 TEST_P(LegalMessageLineTest, Parsing) { | 104 TEST_P(LegalMessageLineTest, Parsing) { |
| 105 scoped_ptr<base::Value> value( | 105 std::unique_ptr<base::Value> value( |
| 106 base::JSONReader::Read(GetParam().message_json)); | 106 base::JSONReader::Read(GetParam().message_json)); |
| 107 ASSERT_TRUE(value); | 107 ASSERT_TRUE(value); |
| 108 base::DictionaryValue* dictionary = nullptr; | 108 base::DictionaryValue* dictionary = nullptr; |
| 109 EXPECT_TRUE(value->GetAsDictionary(&dictionary)); | 109 EXPECT_TRUE(value->GetAsDictionary(&dictionary)); |
| 110 ASSERT_TRUE(dictionary); | 110 ASSERT_TRUE(dictionary); |
| 111 LegalMessageLines actual_lines; | 111 LegalMessageLines actual_lines; |
| 112 LegalMessageLine::Parse(*dictionary, &actual_lines); | 112 LegalMessageLine::Parse(*dictionary, &actual_lines); |
| 113 | 113 |
| 114 EXPECT_EQ(GetParam().expected_lines, actual_lines); | 114 EXPECT_EQ(GetParam().expected_lines, actual_lines); |
| 115 }; | 115 }; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 "aA bB cC dD eE fF gG", | 303 "aA bB cC dD eE fF gG", |
| 304 {Link(1, 2, "http://www.example.com/0"), | 304 {Link(1, 2, "http://www.example.com/0"), |
| 305 Link(4, 5, "http://www.example.com/1"), | 305 Link(4, 5, "http://www.example.com/1"), |
| 306 Link(7, 8, "http://www.example.com/2"), | 306 Link(7, 8, "http://www.example.com/2"), |
| 307 Link(10, 11, "http://www.example.com/3"), | 307 Link(10, 11, "http://www.example.com/3"), |
| 308 Link(13, 14, "http://www.example.com/4"), | 308 Link(13, 14, "http://www.example.com/4"), |
| 309 Link(16, 17, "http://www.example.com/5"), | 309 Link(16, 17, "http://www.example.com/5"), |
| 310 Link(19, 20, "http://www.example.com/6")})}})); | 310 Link(19, 20, "http://www.example.com/6")})}})); |
| 311 | 311 |
| 312 } // namespace autofill | 312 } // namespace autofill |
| OLD | NEW |