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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "components/payments/payment_app.mojom.h" | 8 #include "components/payments/payment_app.mojom.h" |
9 #include "content/browser/payments/payment_app_content_unittest_base.h" | 9 #include "content/browser/payments/payment_app_content_unittest_base.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 return manifest; | 52 return manifest; |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class PaymentAppManagerTest : public PaymentAppContentUnitTestBase { | 57 class PaymentAppManagerTest : public PaymentAppContentUnitTestBase { |
58 public: | 58 public: |
59 PaymentAppManagerTest() { | 59 PaymentAppManagerTest() { |
60 manager_ = CreatePaymentAppManager(GURL(kServiceWorkerPattern), | 60 manager_ = CreatePaymentAppManager(GURL(kServiceWorkerPattern), |
61 GURL(kServiceWorkerScript)); | 61 GURL(kServiceWorkerScript)); |
62 EXPECT_NE(manager_, nullptr); | 62 EXPECT_NE(nullptr, manager_); |
63 } | 63 } |
64 | 64 |
65 PaymentAppManager* payment_app_manager() const { return manager_; } | 65 PaymentAppManager* payment_app_manager() const { return manager_; } |
66 | 66 |
67 private: | 67 private: |
68 // Owned by payment_app_context_. | 68 // Owned by payment_app_context_. |
69 PaymentAppManager* manager_; | 69 PaymentAppManager* manager_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); | 71 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); |
72 }; | 72 }; |
73 | 73 |
74 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { | 74 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { |
75 bool called = false; | 75 bool called = false; |
76 payments::mojom::PaymentAppManifestError error = payments::mojom:: | 76 payments::mojom::PaymentAppManifestError error = payments::mojom:: |
77 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; | 77 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; |
78 SetManifest(payment_app_manager(), kServiceWorkerPattern, | 78 SetManifest(payment_app_manager(), kServiceWorkerPattern, |
79 CreatePaymentAppManifestForTest(), | 79 CreatePaymentAppManifestForTest(), |
80 base::Bind(&SetManifestCallback, &called, &error)); | 80 base::Bind(&SetManifestCallback, &called, &error)); |
81 ASSERT_TRUE(called); | 81 ASSERT_TRUE(called); |
82 | 82 |
83 ASSERT_EQ(error, payments::mojom::PaymentAppManifestError::NONE); | 83 ASSERT_EQ(payments::mojom::PaymentAppManifestError::NONE, error); |
84 | 84 |
85 called = false; | 85 called = false; |
86 payments::mojom::PaymentAppManifestPtr read_manifest; | 86 payments::mojom::PaymentAppManifestPtr read_manifest; |
87 payments::mojom::PaymentAppManifestError read_error = payments::mojom:: | 87 payments::mojom::PaymentAppManifestError read_error = payments::mojom:: |
88 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; | 88 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; |
89 GetManifest( | 89 GetManifest( |
90 payment_app_manager(), kServiceWorkerPattern, | 90 payment_app_manager(), kServiceWorkerPattern, |
91 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); | 91 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); |
92 ASSERT_TRUE(called); | 92 ASSERT_TRUE(called); |
93 | 93 |
94 ASSERT_EQ(read_error, payments::mojom::PaymentAppManifestError::NONE); | 94 ASSERT_EQ(payments::mojom::PaymentAppManifestError::NONE, read_error); |
95 EXPECT_EQ(read_manifest->icon.value(), "payment-app-icon"); | 95 EXPECT_EQ("payment-app-icon", read_manifest->icon.value()); |
96 EXPECT_EQ(read_manifest->name, "Payment App"); | 96 EXPECT_EQ("Payment App", read_manifest->name); |
97 ASSERT_EQ(read_manifest->options.size(), 1U); | 97 ASSERT_EQ(1U, read_manifest->options.size()); |
98 EXPECT_EQ(read_manifest->options[0]->icon.value(), "payment-app-icon"); | 98 EXPECT_EQ("payment-app-icon", read_manifest->options[0]->icon.value()); |
99 EXPECT_EQ(read_manifest->options[0]->name, "Visa ****"); | 99 EXPECT_EQ("Visa ****", read_manifest->options[0]->name); |
100 EXPECT_EQ(read_manifest->options[0]->id, "payment-app-id"); | 100 EXPECT_EQ("payment-app-id", read_manifest->options[0]->id); |
101 ASSERT_EQ(read_manifest->options[0]->enabled_methods.size(), 1U); | 101 ASSERT_EQ(1U, read_manifest->options[0]->enabled_methods.size()); |
102 EXPECT_EQ(read_manifest->options[0]->enabled_methods[0], "visa"); | 102 EXPECT_EQ("visa", read_manifest->options[0]->enabled_methods[0]); |
103 } | 103 } |
104 | 104 |
105 TEST_F(PaymentAppManagerTest, SetManifestWithoutAssociatedServiceWorker) { | 105 TEST_F(PaymentAppManagerTest, SetManifestWithoutAssociatedServiceWorker) { |
106 bool called = false; | 106 bool called = false; |
107 payments::mojom::PaymentAppManifestError error = | 107 payments::mojom::PaymentAppManifestError error = |
108 payments::mojom::PaymentAppManifestError::NONE; | 108 payments::mojom::PaymentAppManifestError::NONE; |
109 SetManifest(payment_app_manager(), kUnregisteredServiceWorkerPattern, | 109 SetManifest(payment_app_manager(), kUnregisteredServiceWorkerPattern, |
110 CreatePaymentAppManifestForTest(), | 110 CreatePaymentAppManifestForTest(), |
111 base::Bind(&SetManifestCallback, &called, &error)); | 111 base::Bind(&SetManifestCallback, &called, &error)); |
112 ASSERT_TRUE(called); | 112 ASSERT_TRUE(called); |
113 | 113 |
114 EXPECT_EQ(error, payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER); | 114 EXPECT_EQ(payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER, error); |
115 } | 115 } |
116 | 116 |
117 TEST_F(PaymentAppManagerTest, GetManifestWithoutAssociatedServiceWorker) { | 117 TEST_F(PaymentAppManagerTest, GetManifestWithoutAssociatedServiceWorker) { |
118 bool called = false; | 118 bool called = false; |
119 payments::mojom::PaymentAppManifestPtr read_manifest; | 119 payments::mojom::PaymentAppManifestPtr read_manifest; |
120 payments::mojom::PaymentAppManifestError read_error = | 120 payments::mojom::PaymentAppManifestError read_error = |
121 payments::mojom::PaymentAppManifestError::NONE; | 121 payments::mojom::PaymentAppManifestError::NONE; |
122 GetManifest( | 122 GetManifest( |
123 payment_app_manager(), kUnregisteredServiceWorkerPattern, | 123 payment_app_manager(), kUnregisteredServiceWorkerPattern, |
124 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); | 124 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); |
125 ASSERT_TRUE(called); | 125 ASSERT_TRUE(called); |
126 | 126 |
127 EXPECT_EQ(read_error, | 127 EXPECT_EQ(payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER, |
128 payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER); | 128 read_error); |
129 } | 129 } |
130 | 130 |
131 TEST_F(PaymentAppManagerTest, GetManifestWithNoSavedManifest) { | 131 TEST_F(PaymentAppManagerTest, GetManifestWithNoSavedManifest) { |
132 bool called = false; | 132 bool called = false; |
133 payments::mojom::PaymentAppManifestPtr read_manifest; | 133 payments::mojom::PaymentAppManifestPtr read_manifest; |
134 payments::mojom::PaymentAppManifestError read_error = | 134 payments::mojom::PaymentAppManifestError read_error = |
135 payments::mojom::PaymentAppManifestError::NONE; | 135 payments::mojom::PaymentAppManifestError::NONE; |
136 GetManifest( | 136 GetManifest( |
137 payment_app_manager(), kServiceWorkerPattern, | 137 payment_app_manager(), kServiceWorkerPattern, |
138 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); | 138 base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); |
139 ASSERT_TRUE(called); | 139 ASSERT_TRUE(called); |
140 | 140 |
141 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: | 141 EXPECT_EQ(payments::mojom::PaymentAppManifestError:: |
please use gerrit instead
2016/12/19 20:27:58
Maybe you should put "using payments::mojom::Payme
zino
2016/12/20 17:11:28
Done.
| |
142 MANIFEST_STORAGE_OPERATION_FAILED); | 142 MANIFEST_STORAGE_OPERATION_FAILED, |
143 read_error); | |
143 } | 144 } |
144 | 145 |
145 } // namespace content | 146 } // namespace content |
OLD | NEW |