#include <memory>
#include "base/files/file_path.h"
#include "base/files/file_path_watcher.h"
#include "base/files/file_util.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h"
#include "chrome/browser/media_galleries/media_galleries_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/switches.h"
#include "extensions/test/extension_test_message_listener.h"
namespace {
const char kTestExtensionId[] = …;
const char kTestExtensionPath[] = …;
const char kGetMediaFileSystemsCmd[] = …;
const char kSetupWatchOnValidGalleriesCmd[] = …;
const char kSetupWatchOnUnlistenedValidGalleriesCmd[] = …;
const char kAddGalleryChangedListenerCmd[] = …;
const char kAddCheckingGalleryChangedListenerCmd[] = …;
const char kRemoveGalleryChangedListenerCmd[] = …;
const char kRemoveGalleryWatchCmd[] = …;
const char kSetupWatchOnInvalidGalleryCmd[] = …;
const char kAddGalleryWatchOK[] = …;
const char kGetMediaFileSystemsCallbackOK[] = …;
const char kGetMediaFileSystemsOK[] = …;
const char kAddGalleryChangedListenerOK[] = …;
const char kRemoveGalleryChangedListenerOK[] = …;
const char kRemoveGalleryWatchOK[] = …;
const char kOnGalleryChangedCheckingOK[] = …;
const char kAddGalleryWatchRequestFailed[] = …;
const char kAddGalleryWatchRequestRuntimeError[] = …;
const char kAddGalleryWatchRequestSucceeded[] = …;
const char kGalleryChangedEventReceived[] = …;
}
class MediaGalleriesGalleryWatchApiTest : public extensions::ExtensionApiTest { … };
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
#define MAYBE_BasicGalleryWatch …
#else
#define MAYBE_BasicGalleryWatch …
#endif
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
MAYBE_BasicGalleryWatch) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
#define MAYBE_CorrectResponseOnModifyingWatchedGallery …
#else
#define MAYBE_CorrectResponseOnModifyingWatchedGallery …
#endif
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
MAYBE_CorrectResponseOnModifyingWatchedGallery) { … }
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
#define MAYBE_RemoveListenerAndModifyGallery …
#else
#define MAYBE_RemoveListenerAndModifyGallery …
#endif
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
MAYBE_RemoveListenerAndModifyGallery) { … }
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
SetupGalleryWatchWithoutListeners) { … }
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
SetupGalleryChangedListenerWithoutWatchers) { … }
IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
SetupWatchOnInvalidGallery) { … }