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

Unified Diff: components/autofill/content/public/cpp/autofill_types_struct_traits_unittest.cc

Issue 1999623002: [Autofill] Add typemap for autofill:FormFieldData and autofill::FormData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from dcheng Created 4 years, 6 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: components/autofill/content/public/cpp/autofill_types_struct_traits_unittest.cc
diff --git a/components/autofill/content/public/cpp/autofill_types_struct_traits_unittest.cc b/components/autofill/content/public/cpp/autofill_types_struct_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9b2958502c0de2bd887798ab568910f3f718e5b
--- /dev/null
+++ b/components/autofill/content/public/cpp/autofill_types_struct_traits_unittest.cc
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "components/autofill/content/public/interfaces/test_autofill_types.mojom.h"
+#include "components/autofill/core/browser/autofill_test_utils.h"
+#include "components/autofill/core/common/form_data.h"
+#include "components/autofill/core/common/form_field_data.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace autofill {
+
+class AutofillTypeTraitsTestImpl : public testing::Test,
+ public mojom::TypeTraitsTest {
+ public:
+ AutofillTypeTraitsTestImpl() {}
+
+ mojom::TypeTraitsTestPtr GetTypeTraitsTestProxy() {
+ return bindings_.CreateInterfacePtrAndBind(this);
+ }
+
+ // mojom::TypeTraitsTest:
+ void PassFormData(const FormData& s,
+ const PassFormDataCallback& callback) override {
+ callback.Run(s);
+ }
+
+ void PassFormFieldData(const FormFieldData& s,
+ const PassFormFieldDataCallback& callback) override {
+ callback.Run(s);
+ }
+
+ private:
+ base::MessageLoop loop_;
+
+ mojo::BindingSet<TypeTraitsTest> bindings_;
+};
+
+TEST_F(AutofillTypeTraitsTestImpl, PassFormFieldData) {
+ FormFieldData input;
+ const std::vector<const char*> kOptions = {"Option1", "Option2", "Option3",
+ "Option4"};
+ test::CreateTestSelectField("TestLabel", "TestName", "TestValue", kOptions,
+ kOptions, 4, &input);
+
+ base::RunLoop loop;
+ mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy();
+ proxy->PassFormFieldData(input, [&input, &loop](const FormFieldData& passed) {
+ EXPECT_TRUE(input.SameFieldAs(passed));
+ EXPECT_EQ(input.option_values, passed.option_values);
+ EXPECT_EQ(input.option_contents, passed.option_contents);
+ loop.Quit();
+ });
+ loop.Run();
+}
+
+TEST_F(AutofillTypeTraitsTestImpl, PassFormData) {
+ FormData input;
+ test::CreateTestAddressFormData(&input);
+
+ base::RunLoop loop;
+ mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy();
+ proxy->PassFormData(input, [&input, &loop](const FormData& passed) {
+ EXPECT_TRUE(input.SameFormAs(passed));
+ loop.Quit();
+ });
+ loop.Run();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698