Commit 814cce45 authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Autofill suggestion implementation. Includes unit tests.

Bug: 763797
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9ba29392c1b16a64cadf4792cdb7b2a947ee04eb
Reviewed-on: https://chromium-review.googlesource.com/744429
Commit-Queue: John Wu <jzw@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513228}
parent 23e5728e
...@@ -24,6 +24,7 @@ config("config") { ...@@ -24,6 +24,7 @@ config("config") {
# and CrNetChromeWebView frameworks. # and CrNetChromeWebView frameworks.
ios_web_view_public_headers = [ ios_web_view_public_headers = [
"public/ChromeWebView.h", "public/ChromeWebView.h",
"public/cwv_autofill_suggestion.h",
"public/cwv_export.h", "public/cwv_export.h",
"public/cwv_html_element.h", "public/cwv_html_element.h",
"public/cwv_navigation_action.h", "public/cwv_navigation_action.h",
...@@ -58,6 +59,8 @@ ios_web_view_sources = [ ...@@ -58,6 +59,8 @@ ios_web_view_sources = [
"internal/app/application_context.h", "internal/app/application_context.h",
"internal/app/web_view_io_thread.h", "internal/app/web_view_io_thread.h",
"internal/app/web_view_io_thread.mm", "internal/app/web_view_io_thread.mm",
"internal/autofill/cwv_autofill_suggestion.mm",
"internal/autofill/cwv_autofill_suggestion_internal.h",
"internal/autofill/web_view_personal_data_manager_factory.cc", "internal/autofill/web_view_personal_data_manager_factory.cc",
"internal/autofill/web_view_personal_data_manager_factory.h", "internal/autofill/web_view_personal_data_manager_factory.h",
"internal/content_settings/web_view_cookie_settings_factory.cc", "internal/content_settings/web_view_cookie_settings_factory.cc",
...@@ -154,6 +157,7 @@ ios_web_view_deps = [ ...@@ -154,6 +157,7 @@ ios_web_view_deps = [
"//base", "//base",
"//components/autofill/core/browser", "//components/autofill/core/browser",
"//components/autofill/core/common", "//components/autofill/core/common",
"//components/autofill/ios/browser",
"//components/content_settings/core/browser", "//components/content_settings/core/browser",
"//components/flags_ui", "//components/flags_ui",
"//components/infobars/core", "//components/infobars/core",
...@@ -226,6 +230,7 @@ ios_framework_bundle("web_view") { ...@@ -226,6 +230,7 @@ ios_framework_bundle("web_view") {
test("ios_web_view_unittests") { test("ios_web_view_unittests") {
testonly = true testonly = true
sources = [ sources = [
"internal/autofill/cwv_autofill_suggestion_unittest.mm",
"internal/cwv_html_element_unittest.mm", "internal/cwv_html_element_unittest.mm",
"internal/cwv_preferences_unittest.mm", "internal/cwv_preferences_unittest.mm",
"internal/cwv_preview_element_info_unittest.mm", "internal/cwv_preview_element_info_unittest.mm",
......
// Copyright 2017 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.
#import "ios/web_view/internal/autofill/cwv_autofill_suggestion_internal.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#import "components/autofill/ios/browser/form_suggestion.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation CWVAutofillSuggestion
@synthesize formSuggestion = _formSuggestion;
@synthesize formName = _formName;
@synthesize fieldName = _fieldName;
- (instancetype)initWithFormSuggestion:(FormSuggestion*)formSuggestion
formName:(NSString*)formName
fieldName:(NSString*)fieldName {
self = [super init];
if (self) {
_formSuggestion = formSuggestion;
_formName = [formName copy];
_fieldName = [fieldName copy];
}
return self;
}
#pragma mark - Public Methods
- (NSString*)value {
return [_formSuggestion.value copy];
}
- (NSString*)displayDescription {
return [_formSuggestion.displayDescription copy];
}
#pragma mark - NSObject
- (NSString*)debugDescription {
return [NSString stringWithFormat:@"%@ value: %@, displayDescription: %@",
super.debugDescription, self.value,
self.displayDescription];
}
@end
// Copyright 2017 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.
#ifndef IOS_WEB_VIEW_INTERNAL_AUTOFILL_CWV_AUTOFILL_SUGGESTION_INTERNAL_H_
#define IOS_WEB_VIEW_INTERNAL_AUTOFILL_CWV_AUTOFILL_SUGGESTION_INTERNAL_H_
#import "ios/web_view/public/cwv_autofill_suggestion.h"
NS_ASSUME_NONNULL_BEGIN
@class FormSuggestion;
@interface CWVAutofillSuggestion ()
- (instancetype)initWithFormSuggestion:(FormSuggestion*)formSuggestion
formName:(NSString*)formName
fieldName:(NSString*)fieldName
NS_DESIGNATED_INITIALIZER;
// The internal autofill form suggestion.
@property(nonatomic, readonly) FormSuggestion* formSuggestion;
@end
NS_ASSUME_NONNULL_END
#endif // IOS_WEB_VIEW_INTERNAL_AUTOFILL_CWV_AUTOFILL_SUGGESTION_INTERNAL_H_
// Copyright 2017 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.
#import "ios/web_view/internal/autofill/cwv_autofill_suggestion_internal.h"
#import <Foundation/Foundation.h>
#import "components/autofill/ios/browser/form_suggestion.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios_web_view {
using CWVAutofillSuggestionTest = PlatformTest;
// Tests CWVAutofillSuggestion initialization.
TEST_F(CWVAutofillSuggestionTest, Initialization) {
NSString* formName = @"TestFormName";
NSString* fieldName = @"TestFieldName";
FormSuggestion* formSuggestion =
[FormSuggestion suggestionWithValue:@"TestValue"
displayDescription:@"TestDisplayDescription"
icon:@"TestIcon"
identifier:0];
CWVAutofillSuggestion* suggestion =
[[CWVAutofillSuggestion alloc] initWithFormSuggestion:formSuggestion
formName:formName
fieldName:fieldName];
EXPECT_NSEQ(formName, suggestion.formName);
EXPECT_NSEQ(fieldName, suggestion.fieldName);
EXPECT_NSEQ(formSuggestion.displayDescription, suggestion.displayDescription);
EXPECT_NSEQ(formSuggestion.value, suggestion.value);
EXPECT_EQ(formSuggestion, suggestion.formSuggestion);
}
} // namespace ios_web_view
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
// ChromeWebView. Framework style imports can't be used because multiple // ChromeWebView. Framework style imports can't be used because multiple
// frameworks are built from ios/web_view with different output names. // frameworks are built from ios/web_view with different output names.
#import "cwv_autofill_suggestion.h"
#import "cwv_export.h" #import "cwv_export.h"
#import "cwv_html_element.h" #import "cwv_html_element.h"
#import "cwv_navigation_action.h" #import "cwv_navigation_action.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment