Commit 66cc77c3 authored by Dominic Battre's avatar Dominic Battre Committed by Commit Bot

Simplify use of unique_renderer_ids

The creation of the map was completely redundant, so I have removed it.

Bug: 896173
Change-Id: Ibe28940c458de4f18b28d958e0d4d34581bbdf77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279825
Commit-Queue: Dominic Battré <battre@chromium.org>
Auto-Submit: Dominic Battré <battre@chromium.org>
Reviewed-by: default avatarMatthias Körber <koerber@google.com>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788576}
parent 757dabf7
...@@ -93,16 +93,11 @@ std::vector<base::FilePath> GetTestFiles() { ...@@ -93,16 +93,11 @@ std::vector<base::FilePath> GetTestFiles() {
std::string FormStructuresToString( std::string FormStructuresToString(
const std::map<FormRendererId, std::unique_ptr<FormStructure>>& forms) { const std::map<FormRendererId, std::unique_ptr<FormStructure>>& forms) {
std::map<uint32_t, const FormStructure*> sorted_forms;
for (const auto& form_kv : forms) {
const auto* form = form_kv.second.get();
uint32_t renderer_id = form->unique_renderer_id().value();
EXPECT_TRUE(sorted_forms.emplace(renderer_id, form).second);
}
std::string forms_string; std::string forms_string;
for (const auto& kv : sorted_forms) { // The forms are sorted by renderer ID, which should make the order
const auto* form = kv.second; // deterministic.
for (const auto& kv : forms) {
const auto* form = kv.second.get();
for (const auto& field : *form) { for (const auto& field : *form) {
forms_string += field->Type().ToString(); forms_string += field->Type().ToString();
forms_string += " | " + base::UTF16ToUTF8(field->name); forms_string += " | " + base::UTF16ToUTF8(field->name);
......
...@@ -206,16 +206,11 @@ void FormStructureBrowserTest::GenerateResults(const std::string& input, ...@@ -206,16 +206,11 @@ void FormStructureBrowserTest::GenerateResults(const std::string& input,
std::string FormStructureBrowserTest::FormStructuresToString( std::string FormStructureBrowserTest::FormStructuresToString(
const std::map<FormRendererId, std::unique_ptr<FormStructure>>& forms) { const std::map<FormRendererId, std::unique_ptr<FormStructure>>& forms) {
std::map<uint32_t, const FormStructure*> sorted_forms; std::string forms_string;
// The forms are sorted by renderer ID, which should make the order
// deterministic.
for (const auto& form_kv : forms) { for (const auto& form_kv : forms) {
const auto* form = form_kv.second.get(); const auto* form = form_kv.second.get();
uint32_t renderer_id = form->unique_renderer_id().value();
EXPECT_TRUE(sorted_forms.emplace(renderer_id, form).second);
}
std::string forms_string;
for (const auto& form_kv : sorted_forms) {
const auto* form = form_kv.second;
for (const auto& field : *form) { for (const auto& field : *form) {
std::string name = base::UTF16ToUTF8(field->name); std::string name = base::UTF16ToUTF8(field->name);
if (base::StartsWith(name, "gChrome~field~", if (base::StartsWith(name, "gChrome~field~",
......
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