#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/containers/contains.h"
#include "base/files/file_util.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/extension_action_test_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_user_test_base.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/crx_file/id_util.h"
#include "components/policy/core/common/policy_map.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/api/extension_action/action_info.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace {
ManifestLocation;
class ToolbarActionsModelTestObserver : public ToolbarActionsModel::Observer { … };
ToolbarActionsModelTestObserver::ToolbarActionsModelTestObserver(
ToolbarActionsModel* model)
: … { … }
ToolbarActionsModelTestObserver::~ToolbarActionsModelTestObserver() { … }
}
class ToolbarActionsModelUnitTest
: public extensions::ExtensionServiceUserTestBase { … };
void ToolbarActionsModelUnitTest::Init() { … }
void ToolbarActionsModelUnitTest::InitToolbarModelAndObserver() { … }
void ToolbarActionsModelUnitTest::TearDown() { … }
void ToolbarActionsModelUnitTest::RunEmitUserHistogramsTest(
int incremented_histogram_count) { … }
testing::AssertionResult ToolbarActionsModelUnitTest::AddExtension(
const scoped_refptr<const extensions::Extension>& extension) { … }
testing::AssertionResult ToolbarActionsModelUnitTest::RemoveExtension(
const scoped_refptr<const extensions::Extension>& extension) { … }
testing::AssertionResult ToolbarActionsModelUnitTest::AddActionExtensions() { … }
testing::AssertionResult
ToolbarActionsModelUnitTest::AddBrowserActionExtensions() { … }
bool ToolbarActionsModelUnitTest::ModelHasActionForId(
const std::string& id) const { … }
testing::AssertionResult ToolbarActionsModelUnitTest::AddAndVerifyExtensions(
const extensions::ExtensionList& extensions) { … }
TEST_F(ToolbarActionsModelUnitTest, BasicToolbarActionsModelTest) { … }
TEST_F(ToolbarActionsModelUnitTest, NewToolbarExtensionsAreUnpinned) { … }
TEST_F(ToolbarActionsModelUnitTest, TestToolbarExtensionTypesEnabledSwitch) { … }
TEST_F(ToolbarActionsModelUnitTest, PinnedStateIsTransferredToIncognito) { … }
TEST_F(ToolbarActionsModelUnitTest,
MovingPinnedActionsTransfersBetweenIncognito) { … }
TEST_F(ToolbarActionsModelUnitTest, ActionsToolbarIncognitoEnableExtension) { … }
TEST_F(ToolbarActionsModelUnitTest, ModelWaitsForExtensionSystemReady) { … }
TEST_F(ToolbarActionsModelUnitTest, AddUserScriptExtension) { … }
TEST_F(ToolbarActionsModelUnitTest, IsActionPinnedCorrespondsToPinningState) { … }
TEST_F(ToolbarActionsModelUnitTest,
TogglingVisibilityAppendsToPinnedExtensions) { … }
TEST_F(ToolbarActionsModelUnitTest, ChangesToPinningNotifiesObserver) { … }
TEST_F(ToolbarActionsModelUnitTest, ChangesToPinningSavedInExtensionPrefs) { … }
TEST_F(ToolbarActionsModelUnitTest, ChangesToExtensionPrefsReflectedInModel) { … }
TEST_F(ToolbarActionsModelUnitTest,
MismatchInPinnedExtensionPreferencesNotReflectedInModel) { … }
TEST_F(ToolbarActionsModelUnitTest, PinnedExtensionsFilteredOnInitialization) { … }
TEST_F(ToolbarActionsModelUnitTest, ChangesToPinnedOrderSavedInExtensionPrefs) { … }
TEST_F(ToolbarActionsModelUnitTest, PinStateErasedOnUninstallation) { … }
TEST_F(ToolbarActionsModelUnitTest, ForcePinnedByPolicy) { … }
TEST_F(ToolbarActionsModelUnitTest, UnloadedExtensionsPinnedStatePreserved) { … }
TEST_F(ToolbarActionsModelUnitTest, InitActionList_EmitUserHistograms) { … }
TEST_F(ToolbarActionsModelUnitTest, InitActionList_NonUserEmitHistograms) { … }