OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <utility> | 5 #include <utility> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); | 1614 inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); |
1615 inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111")); | 1615 inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111")); |
1616 | 1616 |
1617 inputs.push_back( | 1617 inputs.push_back( |
1618 CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); | 1618 CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); |
1619 inputs[1].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Rick Roman")); | 1619 inputs[1].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Rick Roman")); |
1620 inputs[1].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12")); | 1620 inputs[1].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12")); |
1621 inputs[1].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("1997")); | 1621 inputs[1].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("1997")); |
1622 inputs[1].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); | 1622 inputs[1].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); |
1623 inputs[1].SetTypeForMaskedCard(kVisaCard); | 1623 inputs[1].SetTypeForMaskedCard(kVisaCard); |
| 1624 inputs[1].SetServerStatus(CreditCard::EXPIRED); |
1624 | 1625 |
1625 table_->SetServerCreditCards(inputs); | 1626 table_->SetServerCreditCards(inputs); |
1626 | 1627 |
1627 std::vector<CreditCard*> outputs; | 1628 std::vector<CreditCard*> outputs; |
1628 ASSERT_TRUE(table_->GetServerCreditCards(&outputs)); | 1629 ASSERT_TRUE(table_->GetServerCreditCards(&outputs)); |
1629 ASSERT_EQ(inputs.size(), outputs.size()); | 1630 ASSERT_EQ(inputs.size(), outputs.size()); |
1630 | 1631 |
1631 // Ordering isn't guaranteed, so fix the ordering if it's backwards. | 1632 // Ordering isn't guaranteed, so fix the ordering if it's backwards. |
1632 if (outputs[1]->server_id() == inputs[0].server_id()) | 1633 if (outputs[1]->server_id() == inputs[0].server_id()) |
1633 std::swap(outputs[0], outputs[1]); | 1634 std::swap(outputs[0], outputs[1]); |
1634 | 1635 |
1635 // GUIDs for server cards are dynamically generated so will be different | 1636 // GUIDs for server cards are dynamically generated so will be different |
1636 // after reading from the DB. Check they're valid, but otherwise don't count | 1637 // after reading from the DB. Check they're valid, but otherwise don't count |
1637 // them in the comparison. | 1638 // them in the comparison. |
1638 inputs[0].set_guid(std::string()); | 1639 inputs[0].set_guid(std::string()); |
1639 inputs[1].set_guid(std::string()); | 1640 inputs[1].set_guid(std::string()); |
1640 outputs[0]->set_guid(std::string()); | 1641 outputs[0]->set_guid(std::string()); |
1641 outputs[1]->set_guid(std::string()); | 1642 outputs[1]->set_guid(std::string()); |
1642 | 1643 |
1643 EXPECT_EQ(inputs[0], *outputs[0]); | 1644 EXPECT_EQ(inputs[0], *outputs[0]); |
1644 EXPECT_EQ(inputs[1], *outputs[1]); | 1645 EXPECT_EQ(inputs[1], *outputs[1]); |
1645 | 1646 |
| 1647 EXPECT_EQ(CreditCard::OK, outputs[0]->GetServerStatus()); |
| 1648 EXPECT_EQ(CreditCard::EXPIRED, outputs[1]->GetServerStatus()); |
| 1649 |
1646 STLDeleteContainerPointers(outputs.begin(), outputs.end()); | 1650 STLDeleteContainerPointers(outputs.begin(), outputs.end()); |
1647 } | 1651 } |
1648 | 1652 |
1649 TEST_F(AutofillTableTest, MaskUnmaskServerCards) { | 1653 TEST_F(AutofillTableTest, MaskUnmaskServerCards) { |
1650 base::string16 masked_number(ASCIIToUTF16("1111")); | 1654 base::string16 masked_number(ASCIIToUTF16("1111")); |
1651 std::vector<CreditCard> inputs; | 1655 std::vector<CreditCard> inputs; |
1652 inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); | 1656 inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); |
1653 inputs[0].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jay Johnson")); | 1657 inputs[0].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jay Johnson")); |
1654 inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); | 1658 inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); |
1655 inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); | 1659 inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 // The original one should have been replaced. | 1786 // The original one should have been replaced. |
1783 table_->GetAutofillServerProfiles(&outputs); | 1787 table_->GetAutofillServerProfiles(&outputs); |
1784 ASSERT_EQ(1u, outputs.size()); | 1788 ASSERT_EQ(1u, outputs.size()); |
1785 EXPECT_EQ(two.server_id(), outputs[0]->server_id()); | 1789 EXPECT_EQ(two.server_id(), outputs[0]->server_id()); |
1786 | 1790 |
1787 STLDeleteContainerPointers(outputs.begin(), outputs.end()); | 1791 STLDeleteContainerPointers(outputs.begin(), outputs.end()); |
1788 outputs.clear(); | 1792 outputs.clear(); |
1789 } | 1793 } |
1790 | 1794 |
1791 } // namespace autofill | 1795 } // namespace autofill |
OLD | NEW |