chromium/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/ui/search_engines/keyword_editor_controller.h"

#include <memory>
#include <string>

#include "base/compiler_specific.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory_test_util.h"
#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/browser/ui/search_engines/template_url_table_model.h"
#include "chrome/test/base/testing_profile.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/choice_made_location.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/models/table_model_observer.h"

ASCIIToUTF16;

static const std::u16string kA(u"a");
static const std::u16string kA1(u"a1");
static const std::u16string kB(u"b");
static const std::u16string kB1(u"b1");
static const std::u16string kManaged(u"managed");

// Base class for keyword editor tests. Creates a profile containing an
// empty TemplateURLService.
class KeywordEditorControllerTest : public testing::Test,
                                    public ui::TableModelObserver {};

class KeywordEditorControllerNoWebDataTest
    : public KeywordEditorControllerTest {};

class KeywordEditorControllerManagedDSPTest
    : public KeywordEditorControllerTest {};

// Tests adding a TemplateURL.
TEST_F(KeywordEditorControllerTest, Add) {}

// Tests modifying a TemplateURL.
TEST_F(KeywordEditorControllerTest, Modify) {}

// Tests making a TemplateURL the default search provider.
TEST_F(KeywordEditorControllerTest, MakeDefault) {}

// Tests that a TemplateURL can't be made the default if the default search
// provider is managed via policy.
TEST_F(KeywordEditorControllerManagedDSPTest, CannotSetDefaultWhileManaged) {}

// Tests that a TemplateURL can be made the default if the default search
// provider is recommended via policy.
TEST_F(KeywordEditorControllerManagedDSPTest, SetDefaultWhileRecommended) {}

// Tests that a recomended search provider does not persist when a different
// recommended provider is applied via policy.
TEST_F(KeywordEditorControllerManagedDSPTest, UpdateRecommended) {}

// Tests that a recomended search provider does not persist when a managed
// provider is applied via policy.
TEST_F(KeywordEditorControllerManagedDSPTest, SetManagedWhileRecommended) {}

// Tests that a TemplateURL can't be edited if it is the managed default search
// provider.
TEST_F(KeywordEditorControllerManagedDSPTest, EditManagedDefault) {}

// Tests that a `TemplateURL` can be edited if it is the recommended default
// search provider.
TEST_F(KeywordEditorControllerManagedDSPTest, EditRecommendedDefault) {}

TEST_F(KeywordEditorControllerNoWebDataTest, MakeDefaultNoWebData) {}

// Mutates the TemplateURLService and make sure table model is updating
// appropriately.
TEST_F(KeywordEditorControllerTest, MutateTemplateURLService) {}

// Specifies examples for tests that verify ordering of search engines.
struct SearchEngineOrderingTestCase {};

std::unique_ptr<TemplateURL> CreateTemplateUrlForSortingTest(
    SearchEngineOrderingTestCase test_case) {}

TEST_F(KeywordEditorControllerTest, EnginesSortedByName) {}

TEST_F(KeywordEditorControllerTest, EnginesSortedByNameWithManagedSiteSearch) {}

TEST_F(KeywordEditorControllerTest, FeaturedEnterpriseSiteSearch) {}

TEST_F(KeywordEditorControllerTest,
       EnterpriseSiteSearchConflictWithExistingEngines) {}