chromium/components/autofill/core/browser/form_structure_sectioning_util_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/form_structure_sectioning_util.h"

#include <memory>
#include <string>
#include <vector>

#include "autofill_test_utils.h"
#include "base/check_op.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/autocomplete_parsing_util.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/autofill/core/common/signatures.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {

Bucket;
BucketsAre;

constexpr char kNumberOfSectionsHistogram[] =;
constexpr char kFieldsPerSectionHistogram[] =;

// The key information from which we build the `FormFieldData` objects for a
// unittest.
struct FieldTemplate {};

// Returns fields to be sectioned.
std::vector<std::unique_ptr<AutofillField>> CreateFields(
    const std::vector<FieldTemplate>& field_templates) {}

std::vector<Section> GetSections(
    const std::vector<std::unique_ptr<AutofillField>>& fields) {}

class FormStructureSectioningTest : public testing::Test {};

// This refers to the example from the code comment in form_sectioning_util.h.
std::vector<std::unique_ptr<AutofillField>> CreateExampleFields() {}

TEST_F(FormStructureSectioningTest, ExampleFormNoSectioningMode) {}

// Tests that an invisible <select> does not start a new section. Consider the
// following form:
//   <form>
//     <div style="display: none">
//       Name: <input>
//       Country: <select>...</select>
//       ...
//     </div>
//     <div style="display: block">
//       Name: <input>
//       Country: <select>...</select>
//       ...
//     </div>
//   </form>
// The fields from the first <div> must be in a different section than the
// fields in the second <div>. In particular, the first <select> (even though it
// *is* sectionable) must not start a section to which the name <input> is then
// added.
TEST_F(FormStructureSectioningTest,
       SelectFieldOfHiddenSectionDoesNotLeakIntoFollowingSection) {}

// Tests that repeated sequences of state and country do not start a new
// section. Consider the following form:
//   <form>
//     Name: <input>
//     Address line 1: <input>
//     Address line 2: <input>
//     <div style="display: block">
//       State: <select>...</select>
//       Country: <select>...</select>
//     </div>
//     <div style="display: none">
//       State: <select>...</select>
//       Country: <select>...</select>
//     </div>
//     Phone: <input>
//   </form>
// The fields in the second <div> should not start a new section.
TEST_F(FormStructureSectioningTest,
       RepeatedSequenceOfStateCountryEtcDoesNotBreakSection) {}

}  // namespace
}  // namespace autofill