| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 masked_card.SetTypeForMaskedCard(kVisaCard); | 1731 masked_card.SetTypeForMaskedCard(kVisaCard); |
| 1732 | 1732 |
| 1733 std::vector<CreditCard> inputs; | 1733 std::vector<CreditCard> inputs; |
| 1734 inputs.push_back(masked_card); | 1734 inputs.push_back(masked_card); |
| 1735 test::SetServerCreditCards(table_.get(), inputs); | 1735 test::SetServerCreditCards(table_.get(), inputs); |
| 1736 | 1736 |
| 1737 ScopedVector<CreditCard> outputs; | 1737 ScopedVector<CreditCard> outputs; |
| 1738 table_->GetServerCreditCards(&outputs.get()); | 1738 table_->GetServerCreditCards(&outputs.get()); |
| 1739 ASSERT_EQ(1u, outputs.size()); | 1739 ASSERT_EQ(1u, outputs.size()); |
| 1740 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); | 1740 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); |
| 1741 EXPECT_EQ(0U, outputs[0]->use_count()); | 1741 EXPECT_EQ(1U, outputs[0]->use_count()); |
| 1742 EXPECT_EQ(base::Time(), outputs[0]->use_date()); | 1742 EXPECT_NE(base::Time(), outputs[0]->use_date()); |
| 1743 outputs.clear(); | 1743 outputs.clear(); |
| 1744 | 1744 |
| 1745 // Update the usage stats; make sure they're reflected in GetServerProfiles. | 1745 // Update the usage stats; make sure they're reflected in GetServerProfiles. |
| 1746 inputs.back().set_use_count(4U); | 1746 inputs.back().set_use_count(4U); |
| 1747 inputs.back().set_use_date(base::Time::Now()); | 1747 inputs.back().set_use_date(base::Time()); |
| 1748 table_->UpdateServerCardUsageStats(inputs.back()); | 1748 table_->UpdateServerCardUsageStats(inputs.back()); |
| 1749 table_->GetServerCreditCards(&outputs.get()); | 1749 table_->GetServerCreditCards(&outputs.get()); |
| 1750 ASSERT_EQ(1u, outputs.size()); | 1750 ASSERT_EQ(1u, outputs.size()); |
| 1751 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); | 1751 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); |
| 1752 EXPECT_EQ(4U, outputs[0]->use_count()); | 1752 EXPECT_EQ(4U, outputs[0]->use_count()); |
| 1753 EXPECT_NE(base::Time(), outputs[0]->use_date()); | 1753 EXPECT_EQ(base::Time(), outputs[0]->use_date()); |
| 1754 outputs.clear(); | 1754 outputs.clear(); |
| 1755 | 1755 |
| 1756 // Setting the cards again shouldn't delete the usage stats. | 1756 // Setting the cards again shouldn't delete the usage stats. |
| 1757 table_->SetServerCreditCards(inputs); | 1757 table_->SetServerCreditCards(inputs); |
| 1758 table_->GetServerCreditCards(&outputs.get()); | 1758 table_->GetServerCreditCards(&outputs.get()); |
| 1759 ASSERT_EQ(1u, outputs.size()); | 1759 ASSERT_EQ(1u, outputs.size()); |
| 1760 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); | 1760 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); |
| 1761 EXPECT_EQ(4U, outputs[0]->use_count()); | 1761 EXPECT_EQ(4U, outputs[0]->use_count()); |
| 1762 EXPECT_NE(base::Time(), outputs[0]->use_date()); | 1762 EXPECT_EQ(base::Time(), outputs[0]->use_date()); |
| 1763 outputs.clear(); | 1763 outputs.clear(); |
| 1764 | 1764 |
| 1765 // Set a card list where the card is missing --- this should clear metadata. | 1765 // Set a card list where the card is missing --- this should clear metadata. |
| 1766 CreditCard masked_card2(CreditCard::MASKED_SERVER_CARD, "b456"); | 1766 CreditCard masked_card2(CreditCard::MASKED_SERVER_CARD, "b456"); |
| 1767 inputs.back() = masked_card2; | 1767 inputs.back() = masked_card2; |
| 1768 table_->SetServerCreditCards(inputs); | 1768 table_->SetServerCreditCards(inputs); |
| 1769 | 1769 |
| 1770 // Back to the original card list. | 1770 // Back to the original card list. |
| 1771 inputs.back() = masked_card; | 1771 inputs.back() = masked_card; |
| 1772 table_->SetServerCreditCards(inputs); | 1772 table_->SetServerCreditCards(inputs); |
| 1773 table_->GetServerCreditCards(&outputs.get()); | 1773 table_->GetServerCreditCards(&outputs.get()); |
| 1774 ASSERT_EQ(1u, outputs.size()); | 1774 ASSERT_EQ(1u, outputs.size()); |
| 1775 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); | 1775 EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); |
| 1776 EXPECT_EQ(0U, outputs[0]->use_count()); | 1776 EXPECT_EQ(1U, outputs[0]->use_count()); |
| 1777 EXPECT_EQ(base::Time(), outputs[0]->use_date()); | 1777 EXPECT_NE(base::Time(), outputs[0]->use_date()); |
| 1778 outputs.clear(); | 1778 outputs.clear(); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 TEST_F(AutofillTableTest, SetServerProfile) { | 1781 TEST_F(AutofillTableTest, SetServerProfile) { |
| 1782 AutofillProfile one(AutofillProfile::SERVER_PROFILE, "a123"); | 1782 AutofillProfile one(AutofillProfile::SERVER_PROFILE, "a123"); |
| 1783 std::vector<AutofillProfile> inputs; | 1783 std::vector<AutofillProfile> inputs; |
| 1784 inputs.push_back(one); | 1784 inputs.push_back(one); |
| 1785 table_->SetServerProfiles(inputs); | 1785 table_->SetServerProfiles(inputs); |
| 1786 | 1786 |
| 1787 std::vector<AutofillProfile*> outputs; | 1787 std::vector<AutofillProfile*> outputs; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { | 1978 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { |
| 1979 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); | 1979 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 changes.clear(); | 1982 changes.clear(); |
| 1983 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); | 1983 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); |
| 1984 } | 1984 } |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 } // namespace autofill | 1987 } // namespace autofill |
| OLD | NEW |