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

Side by Side Diff: content/browser/payments/payment_app_context_impl_unittest.cc

Issue 2585303002: PaymentApp: Fix params order of EXPECT/ASSERTs in unit tests. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
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 <cstddef> 5 #include <cstddef>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 manifest->name = scope_url.spec(); 64 manifest->name = scope_url.spec();
65 manifest->options.push_back(std::move(option)); 65 manifest->options.push_back(std::move(option));
66 66
67 payments::mojom::PaymentAppManifestError error = payments::mojom:: 67 payments::mojom::PaymentAppManifestError error = payments::mojom::
68 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; 68 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED;
69 bool called = false; 69 bool called = false;
70 SetManifest(manager, scope_url.spec(), std::move(manifest), 70 SetManifest(manager, scope_url.spec(), std::move(manifest),
71 base::Bind(&SetManifestCallback, &called, &error)); 71 base::Bind(&SetManifestCallback, &called, &error));
72 ASSERT_TRUE(called); 72 ASSERT_TRUE(called);
73 73
74 ASSERT_EQ(error, payments::mojom::PaymentAppManifestError::NONE); 74 ASSERT_EQ(payments::mojom::PaymentAppManifestError::NONE, error);
75 } 75 }
76 76
77 private: 77 private:
78 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextTest); 78 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextTest);
79 }; 79 };
80 80
81 TEST_F(PaymentAppContextTest, Test) { 81 TEST_F(PaymentAppContextTest, Test) {
82 static const struct { 82 static const struct {
83 const char* scopeUrl; 83 const char* scopeUrl;
84 const char* scriptUrl; 84 const char* scriptUrl;
85 } kPaymentAppInfo[] = { 85 } kPaymentAppInfo[] = {
86 {"https://example.com/a", "https://example.com/a/script.js"}, 86 {"https://example.com/a", "https://example.com/a/script.js"},
87 {"https://example.com/b", "https://example.com/b/script.js"}, 87 {"https://example.com/b", "https://example.com/b/script.js"},
88 {"https://example.com/c", "https://example.com/c/script.js"}}; 88 {"https://example.com/c", "https://example.com/c/script.js"}};
89 89
90 for (size_t i = 0; i < arraysize(kPaymentAppInfo); i++) { 90 for (size_t i = 0; i < arraysize(kPaymentAppInfo); i++) {
91 CreatePaymentApp(GURL(kPaymentAppInfo[i].scopeUrl), 91 CreatePaymentApp(GURL(kPaymentAppInfo[i].scopeUrl),
92 GURL(kPaymentAppInfo[i].scriptUrl)); 92 GURL(kPaymentAppInfo[i].scriptUrl));
93 } 93 }
94 94
95 PaymentAppContext::Manifests manifests; 95 PaymentAppContext::Manifests manifests;
96 bool called = false; 96 bool called = false;
97 GetAllManifests(base::Bind(&GetAllManifestsCallback, &called, &manifests)); 97 GetAllManifests(base::Bind(&GetAllManifestsCallback, &called, &manifests));
98 ASSERT_TRUE(called); 98 ASSERT_TRUE(called);
99 99
100 ASSERT_EQ(manifests.size(), 3U); 100 ASSERT_EQ(3U, manifests.size());
101 size_t i = 0; 101 size_t i = 0;
102 for (const auto& manifest : manifests) { 102 for (const auto& manifest : manifests) {
103 EXPECT_EQ(manifest.second->icon.value(), "payment-app-icon"); 103 EXPECT_EQ("payment-app-icon", manifest.second->icon.value());
please use gerrit instead 2016/12/19 20:27:58 If you construct an expected manifest, can you com
zino 2016/12/20 17:11:28 Done. I agree with you. It makes the codes simple
please use gerrit instead 2016/12/20 17:23:36 You're right, it's better to keep error messages c
104 EXPECT_EQ(manifest.second->name, kPaymentAppInfo[i++].scopeUrl); 104 EXPECT_EQ(kPaymentAppInfo[i++].scopeUrl, manifest.second->name);
105 ASSERT_EQ(manifest.second->options.size(), 1U); 105 ASSERT_EQ(1U, manifest.second->options.size());
106 EXPECT_EQ(manifest.second->options[0]->icon.value(), "payment-app-icon"); 106 EXPECT_EQ("payment-app-icon", manifest.second->options[0]->icon.value());
107 EXPECT_EQ(manifest.second->options[0]->name, "Visa ****"); 107 EXPECT_EQ("Visa ****", manifest.second->options[0]->name);
108 EXPECT_EQ(manifest.second->options[0]->id, "payment-app-id"); 108 EXPECT_EQ("payment-app-id", manifest.second->options[0]->id);
109 ASSERT_EQ(manifest.second->options[0]->enabled_methods.size(), 1U); 109 ASSERT_EQ(1U, manifest.second->options[0]->enabled_methods.size());
110 EXPECT_EQ(manifest.second->options[0]->enabled_methods[0], "visa"); 110 EXPECT_EQ("visa", manifest.second->options[0]->enabled_methods[0]);
111 } 111 }
112 } 112 }
113 113
114 } // namespace content 114 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698