Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: content/browser/payments/payment_manager_unittest.cc

Issue 2856973002: PaymentHandler: Implement PaymentInstruments.clear(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.clear(). Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 195d3527be5648e00e3a2d9db0b2f9543b7f324e..07e522c1d4358f8e532c9ad32bceba0d049bf2b0 100644
--- a/content/browser/payments/payment_manager_unittest.cc
+++ b/content/browser/payments/payment_manager_unittest.cc
@@ -71,6 +71,11 @@ void GetPaymentInstrumentCallback(PaymentInstrumentPtr* out_instrument,
*out_status = status;
}
+void ClearPaymentInstrumentsCallback(PaymentHandlerStatus* out_status,
+ PaymentHandlerStatus status) {
+ *out_status = status;
+}
+
} // namespace
class PaymentManagerTest : public PaymentAppContentUnitTestBase {
@@ -123,6 +128,12 @@ class PaymentManagerTest : public PaymentAppContentUnitTestBase {
base::RunLoop().RunUntilIdle();
}
+ void ClearPaymentInstruments(PaymentHandlerStatus* out_status) {
+ manager_->ClearPaymentInstruments(
+ base::Bind(&ClearPaymentInstrumentsCallback, out_status));
+ base::RunLoop().RunUntilIdle();
+ }
+
private:
// Owned by payment_app_context_.
PaymentManager* manager_;
@@ -294,4 +305,42 @@ TEST_F(PaymentManagerTest, KeysOfPaymentInstruments) {
ASSERT_EQ("test_key2", keys[2]);
}
+TEST_F(PaymentManagerTest, ClearPaymentInstruments) {
+ PaymentHandlerStatus status = PaymentHandlerStatus::NOT_FOUND;
+ std::vector<std::string> keys;
+ KeysOfPaymentInstruments(&keys, &status);
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, 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);
+ }
+
+ status = PaymentHandlerStatus::NOT_FOUND;
+ KeysOfPaymentInstruments(&keys, &status);
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, status);
+ ASSERT_EQ(3U, keys.size());
+
+ status = PaymentHandlerStatus::NOT_FOUND;
+ ClearPaymentInstruments(&status);
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, status);
+
+ status = PaymentHandlerStatus::NOT_FOUND;
+ KeysOfPaymentInstruments(&keys, &status);
+ ASSERT_EQ(PaymentHandlerStatus::SUCCESS, status);
+ ASSERT_EQ(0U, keys.size());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698