Index: content/browser/payments/payment_manager_unittest.cc |
diff --git a/content/browser/payments/payment_manager_unittest.cc b/content/browser/payments/payment_manager_unittest.cc |
index 37d48295ad534b9e7b64ce88f9cc2daf03686883..195d3527be5648e00e3a2d9db0b2f9543b7f324e 100644 |
--- a/content/browser/payments/payment_manager_unittest.cc |
+++ b/content/browser/payments/payment_manager_unittest.cc |
@@ -50,6 +50,14 @@ void SetPaymentInstrumentCallback(PaymentHandlerStatus* out_status, |
*out_status = status; |
} |
+void KeysOfPaymentInstrumentsCallback(std::vector<std::string>* out_keys, |
+ PaymentHandlerStatus* out_status, |
+ const std::vector<std::string>& keys, |
+ PaymentHandlerStatus status) { |
+ *out_keys = keys; |
+ *out_status = status; |
+} |
+ |
void HasPaymentInstrumentCallback(PaymentHandlerStatus* out_status, |
PaymentHandlerStatus status) { |
*out_status = status; |
@@ -92,6 +100,13 @@ class PaymentManagerTest : public PaymentAppContentUnitTestBase { |
base::RunLoop().RunUntilIdle(); |
} |
+ void KeysOfPaymentInstruments(std::vector<std::string>* out_keys, |
+ PaymentHandlerStatus* out_status) { |
+ manager_->KeysOfPaymentInstruments( |
+ base::Bind(&KeysOfPaymentInstrumentsCallback, out_keys, out_status)); |
+ base::RunLoop().RunUntilIdle(); |
+ } |
+ |
void HasPaymentInstrument(const std::string& instrument_key, |
PaymentHandlerStatus* out_status) { |
manager_->HasPaymentInstrument( |
@@ -247,4 +262,36 @@ TEST_F(PaymentManagerTest, HasPaymentInstrument) { |
ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, has_status); |
} |
+TEST_F(PaymentManagerTest, KeysOfPaymentInstruments) { |
+ PaymentHandlerStatus keys_status = PaymentHandlerStatus::NOT_FOUND; |
+ std::vector<std::string> keys; |
+ KeysOfPaymentInstruments(&keys, &keys_status); |
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, keys_status); |
+ ASSERT_EQ(0U, keys.size()); |
+ |
+ { |
+ PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; |
+ SetPaymentInstrument("test_key1", PaymentInstrument::New(), &write_status); |
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, write_status); |
+ } |
+ { |
+ PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; |
+ SetPaymentInstrument("test_key3", PaymentInstrument::New(), &write_status); |
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, write_status); |
+ } |
+ { |
+ PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; |
+ SetPaymentInstrument("test_key2", PaymentInstrument::New(), &write_status); |
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, write_status); |
+ } |
+ |
+ keys_status = PaymentHandlerStatus::NOT_FOUND; |
+ KeysOfPaymentInstruments(&keys, &keys_status); |
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, keys_status); |
+ ASSERT_EQ(3U, keys.size()); |
+ ASSERT_EQ("test_key1", keys[0]); |
+ ASSERT_EQ("test_key3", keys[1]); |
+ ASSERT_EQ("test_key2", keys[2]); |
+} |
+ |
} // namespace content |