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

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: Fix gyp Created 4 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: 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..466107d19ff455f994992af86a7ecb3f88107026
--- /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;
+ std::vector<const char*> kOptions = {"Option1", "Option2", "Option3",
vabr (Chromium) 2016/05/23 12:47:37 const std::vector...
leonhsl(Using Gerrit) 2016/05/24 06:38:20 Done. Thanks~
+ "Option4"};
+ test::CreateTestSelectField("TestLabel", "TestName", "TestValue", kOptions,
+ kOptions, 4, &input);
+
+ base::RunLoop loop;
+ mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy();
+ proxy->PassFormFieldData(input, [&](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, [&](const FormData& passed) {
+ EXPECT_TRUE(input.SameFormAs(passed));
+ loop.Quit();
+ });
+ loop.Run();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698