chromium/components/omnibox/browser/search_suggestion_parser_unittest.cc

// Copyright 2018 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/omnibox/browser/search_suggestion_parser.h"

#include <optional>
#include <sstream>

#include "base/base64.h"
#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/omnibox_feature_configs.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/test_scheme_classifier.h"
#include "components/omnibox/common/omnibox_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/omnibox_proto/answer_data.pb.h"
#include "third_party/omnibox_proto/answer_type.pb.h"
#include "third_party/omnibox_proto/entity_info.pb.h"
#include "third_party/omnibox_proto/navigational_intent.pb.h"
#include "third_party/omnibox_proto/rich_answer_template.pb.h"
#include "third_party/omnibox_proto/rich_suggest_template.pb.h"

namespace {

std::string SerializeAndEncodeEntityInfo(
    const omnibox::EntityInfo& entity_info) {}

std::string SerializeAndEncodeGroupsInfo(
    const omnibox::GroupsInfo& groups_info) {}

std::string SerializeAndEncodeRichSuggestTemplate(
    const omnibox::RichSuggestTemplate& suggest_template) {}

std::string NavigationalIntentsToJSON(
    std::vector<omnibox::NavigationalIntent> nav_intents) {}

// (Rudimentary) mechanism comparing two protobuf MessageLite objects.
// This mechanism should be sufficient as long as compared objects don't host
// any maps.
// TODO(ender): Improve the mechanism to be smarter about checking individual
// fields and their values.
bool ProtosAreEqual(const google::protobuf::MessageLite& actual,
                    const google::protobuf::MessageLite& expected) {}

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// DeserializeJsonData:

TEST(SearchSuggestionParserTest, DeserializeNonListJsonIsInvalid) {}

TEST(SearchSuggestionParserTest, DeserializeMalformedJsonIsInvalid) {}

TEST(SearchSuggestionParserTest, DeserializeJsonData) {}

TEST(SearchSuggestionParserTest, DeserializeWithXssiGuard) {}

TEST(SearchSuggestionParserTest, DeserializeWithTrailingComma) {}

////////////////////////////////////////////////////////////////////////////////
// ExtractJsonData:

// TODO(crbug.com/41382281): Add some ExtractJsonData tests.

////////////////////////////////////////////////////////////////////////////////
// ParseSuggestResults:

TEST(SearchSuggestionParserTest, ParseEmptyValueIsInvalid) {}

TEST(SearchSuggestionParserTest, ParseNonSuggestionValueIsInvalid) {}

TEST(SearchSuggestionParserTest, ParseSuggestResults) {}

// Tests that prerender hints can be parsed correctly.
TEST(SearchSuggestionParserTest, ParsePrerenderSuggestion) {}

// Tests that both prefetch and prerender hints can be parsed correctly.
TEST(SearchSuggestionParserTest, ParseBothPrefetchAndPrerenderSuggestion) {}

TEST(SearchSuggestionParserTest, SuggestClassification) {}

TEST(SearchSuggestionParserTest, NavigationClassification) {}

TEST(SearchSuggestionParserTest, ParseSuggestionGroupInfo) {}

TEST(SearchSuggestionParserTest, ParseSuggestionEntityInfo) {}

TEST(SearchSuggestionParserTest, ParseSuggestionTemplateInfo) {}

TEST(SearchSuggestionParserTest, ParseSuggestionTemplateInfoCounterfactual) {}

TEST(SearchSuggestionParserTest, ParseValidTypes) {}

TEST(SearchSuggestionParserTest, ParseValidSubtypes) {}

TEST(SearchSuggestionParserTest, IgnoresExcessiveSubtypeEntries) {}

TEST(SearchSuggestionParserTest, IgnoresMissingSubtypeEntries) {}

TEST(SearchSuggestionParserTest, IgnoresUnexpectedSubtypeValues) {}

TEST(SearchSuggestionParserTest, IgnoresSubtypesIfNotAList) {}

TEST(SearchSuggestionParserTest, SubtypesWithEmptyArraysAreValid) {}

TEST(SearchSuggestionParserTest, BadAnswersFailGracefully) {}

TEST(SearchSuggestionParserTest, ParseCalculatorSuggestion) {}

TEST(SearchSuggestionParserTest, ParseTailSuggestion) {}