Skip to content

Commit

Permalink
[iOS] Change pipes to backticks in /ios/chrome/browser/autofill
Browse files Browse the repository at this point in the history
Please review the CL to ensure that nothing is broken and the script
didn't miss some pipes.

This should allow us to have a better formatting in Xcode.

This CL was uploaded by git cl split.

[email protected]

Bug: 1311955
Change-Id: Ib501643b22baa616dfc3519dc9cde8241face3e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3714315
Reviewed-by: Olivier Robin <[email protected]>
Auto-Submit: Gauthier Ambard <[email protected]>
Commit-Queue: Gauthier Ambard <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1018811}
  • Loading branch information
Gauthier Ambard authored and Chromium LUCI CQ committed Jun 28, 2022
1 parent 76e4a67 commit 4d1bb9b
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 109 deletions.
82 changes: 41 additions & 41 deletions ios/chrome/browser/autofill/autofill_controller_js_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
struct ElementByName {
// The name of the element.
const char* element_name;
// The index in the elements that have |element_name|.
// The index in the elements that have `element_name`.
const int index;
// The option index if the element is a select, -1 otherwise.
const int option_index;
Expand All @@ -62,7 +62,7 @@
return query;
}

// Generates an array of JavaScripts that get each element in |elements| by
// Generates an array of JavaScripts that get each element in `elements` by
// name.
NSArray* GetElementsByNameJavaScripts(const ElementByName elements[],
size_t elements_size) {
Expand Down Expand Up @@ -130,7 +130,7 @@
EXTRACT_VALUE = 1 << 0, // Extract value from WebFormControlElement.
EXTRACT_OPTION_TEXT = 1 << 1, // Extract option text from
// WebFormSelectElement. Only valid when
// |EXTRACT_VALUE| is set.
// `EXTRACT_VALUE` is set.
// This is used for form submission where
// human readable value is captured.
EXTRACT_OPTIONS = 1 << 2, // Extract options from
Expand All @@ -141,7 +141,7 @@
EXTRACT_NONE, EXTRACT_VALUE, EXTRACT_OPTION_TEXT, EXTRACT_OPTIONS,
};

// Gets the attributes to check for a mask in |kFormExtractMasks|.
// Gets the attributes to check for a mask in `kFormExtractMasks`.
NSArray* GetFormFieldAttributeListsToCheck(NSUInteger mask) {
if (!(mask & EXTRACT_VALUE)) {
return @[
Expand Down Expand Up @@ -736,14 +736,14 @@

// clang-format on

// Generates JavaScripts to check a JavaScripts object |results| with the
// expected values given in |expected|, which is a dictionary with string
// Generates JavaScripts to check a JavaScripts object `results` with the
// expected values given in `expected`, which is a dictionary with string
// values for all the keys other than @"option_vaues" and @"option_contents";
// the values of @"option_vaues" and @"option_contents" are arrays of
// strings or undefined. Only attributes in |attributes_to_check| are checked.
// A different expected value is chosen in |expected| for different
// |extract_mask|.
// |index| is the index of the control element in the form. If it is >0, it will
// strings or undefined. Only attributes in `attributes_to_check` are checked.
// A different expected value is chosen in `expected` for different
// `extract_mask`.
// `index` is the index of the control element in the form. If it is >0, it will
// be used to generate a name for nameless elements.
NSString* GenerateElementItemVerifyingJavaScripts(NSString* results,
NSUInteger extract_mask,
Expand Down Expand Up @@ -789,11 +789,11 @@
return [verifying_javascripts componentsJoinedByString:@"&&"];
}

// Generates JavaScripts to check a JavaScripts array |results| with the
// expected values given in |expected|, which is an array of dictionaries; each
// dictionary is the expected values of the corresponding item in |results|.
// Only attributes in |attributes_to_check| are checked. A different expected
// value is chosen in |expected| for different |extract_mask|.
// Generates JavaScripts to check a JavaScripts array `results` with the
// expected values given in `expected`, which is an array of dictionaries; each
// dictionary is the expected values of the corresponding item in `results`.
// Only attributes in `attributes_to_check` are checked. A different expected
// value is chosen in `expected` for different `extract_mask`.
NSString* GenerateTestItemVerifyingJavaScripts(NSString* results,
NSUInteger extract_mask,
NSArray* expected,
Expand Down Expand Up @@ -842,60 +842,60 @@
return main_frame;
}

// Helper method that EXPECTs |javascript| evaluation on page
// |kHTMLForTestingElements| with expectation given by
// |elements_with_true_expected|.
// Helper method that EXPECTs `javascript` evaluation on page
// `kHTMLForTestingElements` with expectation given by
// `elements_with_true_expected`.
void TestExecutingBooleanJavaScriptOnElement(
NSString* javascript,
const ElementByName elements_with_true_expected[],
size_t size_elements_with_true_expected);

// Helper method that EXPECTs
// |__gCrWeb.fill.webFormControlElementToFormField|. This method applies
// |__gCrWeb.fill.webFormControlElementToFormField| on each element in
// |test_data| with all possible extract masks and verify the results.
// `__gCrWeb.fill.webFormControlElementToFormField`. This method applies
// `__gCrWeb.fill.webFormControlElementToFormField` on each element in
// `test_data` with all possible extract masks and verify the results.
void TestWebFormControlElementToFormField(NSArray* test_data,
NSString* tag_name);

// Helper method for testing |javascripts_statement| that evalutate
// |attribute_name| of the elements in |test_data| which has tag name
// |tag_name|. EXPECTs JavaScript evaluation on
// Helper method for testing `javascripts_statement` that evalutate
// `attribute_name` of the elements in `test_data` which has tag name
// `tag_name`. EXPECTs JavaScript evaluation on
// "window.document.getElementsByTagName()"
void TestInputElementDataEvaluation(NSString* javascripts_statement,
NSString* attribute_name,
NSArray* test_data,
NSString* tag_name);

// Helper method that EXPECTs |__gCrWeb.fill.webFormElementToFormData| on
// a form element obtained by |get_form_element_javascripts|. The results
// are verified with |verifying_java_scripts|.
// Helper method that EXPECTs `__gCrWeb.fill.webFormElementToFormData` on
// a form element obtained by `get_form_element_javascripts`. The results
// are verified with `verifying_java_scripts`.
void TestWebFormElementToFormDataForOneForm(
NSString* get_form_element_javascripts,
NSUInteger extract_mask,
NSString* expected_result,
NSString* verifying_javascripts);

// EXPECTs |__gCrWeb.fill.webFormElementToFormData| on all the test data.
// EXPECTs `__gCrWeb.fill.webFormElementToFormData` on all the test data.
void TestWebFormElementToFormData(NSArray* test_items);

// EXPECTs |__gCrWeb.autofill.extractNewForms| on |html|.
// EXPECTs `__gCrWeb.autofill.extractNewForms` on `html`.
void TestExtractNewForms(NSString* html,
BOOL is_origin_window_location,
NSArray* expected_items);

// Helper method that EXPECTs the |java_script| evaluation results on each
// element obtained by JavaScripts in |get_element_java_scripts|. The
// Helper method that EXPECTs the `java_script` evaluation results on each
// element obtained by JavaScripts in `get_element_java_scripts`. The
// expected results are boolean and are true only for elements in
// |get_element_java_scripts_expecting_true| which is subset of
// |get_element_java_scripts|.
// `get_element_java_scripts_expecting_true` which is subset of
// `get_element_java_scripts`.
void ExecuteBooleanJavaScriptOnElementsAndCheck(
NSString* java_script,
NSArray* get_element_java_scripts,
NSArray* get_element_java_scripts_expecting_true);

// Helper method that EXPECTs the |java_script| evaluation results on each
// element obtained by scripts in |get_element_javas_cripts|; the expected
// result is the corresponding entry in |expected_results|.
// Helper method that EXPECTs the `java_script` evaluation results on each
// element obtained by scripts in `get_element_javas_cripts`; the expected
// result is the corresponding entry in `expected_results`.
void ExecuteJavaScriptOnElementsAndCheck(NSString* java_script,
NSArray* get_element_java_scripts,
NSArray* expected_results);
Expand All @@ -910,7 +910,7 @@ void ExecuteJavaScriptOnElementsAndCheck(NSString* java_script,
NSString* javascript,
const ElementByName elements_with_true_expected[],
size_t size_elements_with_true_expected) {
// Elements in |kHTMLForTestingElements|.
// Elements in `kHTMLForTestingElements`.
const ElementByName elementsByName[] = {
{"hl", 0, -1},
{"firstname", 0, -1},
Expand Down Expand Up @@ -1443,9 +1443,9 @@ void ExecuteJavaScriptOnElementsAndCheck(NSString* java_script,
"@')[%" PRIuNS "]",
tag_name, i - 1];
NSDictionary* expected = [test_data objectAtIndex:i];
// Generates JavaScripts to verify the results. Parameter |results| is
// Generates JavaScripts to verify the results. Parameter `results` is
// @"field" as in the evaluation JavaScripts the results are returned in
// |field|.
// `field`.
NSString* verifying_javascripts = GenerateElementItemVerifyingJavaScripts(
@"field", extract_mask, expected, attributes_to_check, -1);
EXPECT_NSEQ(
Expand Down Expand Up @@ -1774,7 +1774,7 @@ void ExecuteJavaScriptOnElementsAndCheck(NSString* java_script,
autofill::FormUtilJavaScriptFeature::GetInstance()
->SetUpForUniqueIDsWithInitialState(main_frame, next_available_id);

// Wait for |SetUpForUniqueIDsWithInitialState| to complete.
// Wait for `SetUpForUniqueIDsWithInitialState` to complete.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^bool {
return [web::test::ExecuteJavaScript(@"document[__gCrWeb.fill.ID_SYMBOL]",
web_state()) intValue] ==
Expand Down Expand Up @@ -1976,7 +1976,7 @@ void ExecuteJavaScriptOnElementsAndCheck(NSString* java_script,
autofill::FormUtilJavaScriptFeature::GetInstance()
->SetUpForUniqueIDsWithInitialState(main_frame, next_available_id);

// Wait for |SetUpForUniqueIDsWithInitialState| to complete.
// Wait for `SetUpForUniqueIDsWithInitialState` to complete.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^bool {
return [web::test::ExecuteJavaScript(@"document[__gCrWeb.fill.ID_SYMBOL]",
web_state()) intValue] ==
Expand Down
16 changes: 8 additions & 8 deletions ios/chrome/browser/autofill/autofill_controller_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ - (void)onNoSuggestionsAvailable {
NSString* const kCreditCardAutofocusFormHtml =
@"<form><input type=\"text\" autofocus autocomplete=\"cc-number\"></form>";

// FAIL if a field with the supplied |name| and |fieldType| is not present on
// the |form|.
// FAIL if a field with the supplied `name` and `fieldType` is not present on
// the `form`.
void CheckField(const FormStructure& form,
ServerFieldType fieldType,
const char* name) {
Expand Down Expand Up @@ -223,16 +223,16 @@ void OnWebDataServiceRequestDone(
void SetUpKeyValueData();

// Blocks until suggestion retrieval has completed.
// If |wait_for_trigger| is yes, wait for the call to
// |retrieveSuggestionsForForm| to avoid considering a former call.
// If `wait_for_trigger` is yes, wait for the call to
// `retrieveSuggestionsForForm` to avoid considering a former call.
void WaitForSuggestionRetrieval(BOOL wait_for_trigger);

// Blocks until |expected_size| forms have been fecthed.
// Blocks until `expected_size` forms have been fetched.
[[nodiscard]] bool WaitForFormFetched(BrowserAutofillManager* manager,
size_t expected_number_of_forms);

// Loads the page and wait until the initial form processing has been done.
// This processing must find |expected_size| forms.
// This processing must find `expected_size` forms.
[[nodiscard]] bool LoadHtmlAndWaitForFormFetched(
NSString* html,
size_t expected_number_of_forms);
Expand Down Expand Up @@ -591,9 +591,9 @@ void OnWebDataServiceRequestDone(
// No value should be returned before anything is loaded via form submission.
ASSERT_EQ(0U, consumer.result_.size());
web::test::ExecuteJavaScript(@"submit.click()", web_state());
// We can't make |consumer| a __block variable because TestConsumer lacks copy
// We can't make `consumer` a __block variable because TestConsumer lacks copy
// construction. We just pass a pointer instead as we know that the callback
// is executed within the life-cyle of |consumer|.
// is executed within the life-cyle of `consumer`.
TestConsumer* consumer_ptr = &consumer;
WaitForCondition(^bool {
web_data_service->GetFormValuesForElementName(u"greeting", std::u16string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void LoadHtml(NSString* html) {
autofill::FormUtilJavaScriptFeature::GetInstance()
->SetUpForUniqueIDsWithInitialState(main_frame, next_available_id);

// Wait for |SetUpForUniqueIDsWithInitialState| to complete.
// Wait for `SetUpForUniqueIDsWithInitialState` to complete.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^bool {
return [web::test::ExecuteJavaScript(@"document[__gCrWeb.fill.ID_SYMBOL]",
web_state()) intValue] ==
Expand Down Expand Up @@ -147,7 +147,7 @@ void RunFormsSearch() {
std::unique_ptr<web::WebState> web_state_;
};

// Tests that |hasBeenInjected| returns YES after |inject| call.
// Tests that `hasBeenInjected` returns YES after `inject` call.
TEST_F(AutofillJavaScriptFeatureTest, InitAndInject) {
LoadHtml(@"<html></html>");
EXPECT_NSEQ(@"object", web::test::ExecuteJavaScript(
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/autofill/autofill_tab_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AutofillTabHelper : public web::WebStateObserver,

~AutofillTabHelper() override;

// Create an AutofillTabHelper and attaches it to the given |web_state|.
// Create an AutofillTabHelper and attaches it to the given `web_state`.
static void CreateForWebState(
web::WebState* web_state,
password_manager::PasswordManager* password_manager);
Expand Down
14 changes: 7 additions & 7 deletions ios/chrome/browser/autofill/form_input_accessory_view_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ FormInputAccessoryAction UMAActionForAssistAction(NSString* assistAction) {

namespace {

// Finds all views of a particular kind if class |aClass| in the subview
// hierarchy of the given |root| view.
// Finds all views of a particular kind if class `aClass` in the subview
// hierarchy of the given `root` view.
NSArray* SubviewsWithClass(UIView* root, Class aClass) {
DCHECK(root);
NSMutableArray* viewsToExamine = [NSMutableArray arrayWithObject:root];
Expand All @@ -74,7 +74,7 @@ FormInputAccessoryAction UMAActionForAssistAction(NSString* assistAction) {
return subviews;
}

// Returns true if |item|'s action name contains |actionName|.
// Returns true if `item`'s action name contains `actionName`.
BOOL ItemActionMatchesName(UIBarButtonItem* item, NSString* actionName) {
SEL itemAction = [item action];
if (!itemAction)
Expand All @@ -85,9 +85,9 @@ BOOL ItemActionMatchesName(UIBarButtonItem* item, NSString* actionName) {
return [itemActionName rangeOfString:actionName].location != NSNotFound;
}

// Finds all UIToolbarItems associated with a given UIToolbar |toolbar| with
// Finds all UIToolbarItems associated with a given UIToolbar `toolbar` with
// action selectors with a name that contains the action name specified by
// |actionName|.
// `actionName`.
NSArray* FindToolbarItemsForActionName(UIToolbar* toolbar,
NSString* actionName) {
NSMutableArray* toolbarItems = [NSMutableArray array];
Expand All @@ -101,7 +101,7 @@ BOOL ItemActionMatchesName(UIBarButtonItem* item, NSString* actionName) {
}

// Finds all UIToolbarItem(s) with action selectors of the name specified by
// |actionName| in any UIToolbars in the view hierarchy below |root|.
// `actionName` in any UIToolbars in the view hierarchy below `root`.
NSArray* FindDescendantToolbarItemsForActionName(UIView* root,
NSString* actionName) {
NSMutableArray* descendants = [NSMutableArray array];
Expand All @@ -116,7 +116,7 @@ BOOL ItemActionMatchesName(UIBarButtonItem* item, NSString* actionName) {
}

// Finds all UIBarButtonItem(s) with action selectors of the name specified by
// |actionName| in the UITextInputAssistantItem passed.
// `actionName` in the UITextInputAssistantItem passed.
NSArray* FindDescendantToolbarItemsForActionName(
UITextInputAssistantItem* inputAssistantItem,
NSString* actionName) {
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/autofill/form_input_egtest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
return result.is_string() ? base::SysUTF8ToNSString(result.GetString()) : @"";
}

// Verifies that |elementId| is the selected element in the web page.
// Verifies that `elementId` is the selected element in the web page.
void AssertElementIsFocused(const std::string& element_id) {
NSString* description =
[NSString stringWithFormat:@"Timeout waiting for the focused element in "
Expand Down
4 changes: 2 additions & 2 deletions ios/chrome/browser/autofill/form_input_navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

// Called when updating the keyboard view. Checks if the page contains a next
// and a previous element.
// |completionHandler| is called with 2 bools, the first indicating if a
// `completionHandler` is called with 2 bools, the first indicating if a
// previous element was found, and the second indicating if a next element was
// found. |completionHandler| cannot be nil.
// found. `completionHandler` cannot be nil.
- (void)fetchPreviousAndNextElementsPresenceWithCompletionHandler:
(void (^)(bool, bool))completionHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef void (^FormSuggestionsReadyCompletion)(
@property(nonatomic, readonly) SuggestionProviderType type;

// Asynchronously retrieves form suggestions from this provider for the
// specified form/field and returns it via |accessoryViewUpdateBlock|. View
// specified form/field and returns it via `accessoryViewUpdateBlock`. View
// will be nil if no accessories are available from this provider.
- (void)retrieveSuggestionsForForm:(const autofill::FormActivityParams&)params
webState:(web::WebState*)webState
Expand Down
6 changes: 3 additions & 3 deletions ios/chrome/browser/autofill/form_structure_browsertest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
// DataDrivenTest:
void GenerateResults(const std::string& input, std::string* output) override;

// Serializes the given |forms| into a string.
// Serializes the given `forms` into a string.
std::string FormStructuresToString(
const std::map<FormGlobalId, std::unique_ptr<FormStructure>>& forms);

Expand Down Expand Up @@ -261,7 +261,7 @@
autofill::FormUtilJavaScriptFeature::GetInstance()
->SetUpForUniqueIDsWithInitialState(main_frame, next_available_id);

// Wait for |SetUpForUniqueIDsWithInitialState| to complete.
// Wait for `SetUpForUniqueIDsWithInitialState` to complete.
return WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^bool {
return [web::test::ExecuteJavaScript(@"document[__gCrWeb.fill.ID_SYMBOL]",
web_state()) intValue] ==
Expand Down Expand Up @@ -312,7 +312,7 @@
}

// Normalize the section by replacing the unique but platform-dependent
// integers in |field->section| with consecutive unique integers.
// integers in `field->section` with consecutive unique integers.
// The section string is of the form "fieldname_id1_id2-suffix", where
// id1, id2 are platform-dependent and thus need to be substituted.
size_t last_underscore = section.find_last_of('_');
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/autofill/form_suggestion_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class WebState;

// Initializes a new FormSuggestionController with the specified WebState and a
// list of FormSuggestionProviders.
// When suggestions are required for an input field, the |providers| will be
// When suggestions are required for an input field, the `providers` will be
// asked (in order) if they can handle the field; the first provider to return
// YES from [FormSuggestionProvider canProviderSuggestionsForForm:field:] will
// be expected to provide those suggestions using [FormSuggestionProvider
Expand Down
Loading

0 comments on commit 4d1bb9b

Please sign in to comment.