chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.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.

#include <stdint.h>

#include <string_view>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/api/extension_action/test_extension_action_api_observer.h"
#include "chrome/browser/extensions/api/extension_action/test_icon_image_observer.h"
#include "chrome/browser/extensions/extension_action_runner.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/extension_action_test_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/overlay_window.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/video_picture_in_picture_window_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_icon_factory.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_test_helper.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_unittest_util.h"

WebContents;

namespace extensions {
namespace {

void ExecuteExtensionAction(Browser* browser, const Extension* extension) {}

const char kEmptyImageDataError[] =;
const char kEmptyPathError[] =;

// Makes sure |bar_rendering| has |model_icon| in the middle (there's additional
// padding that correlates to the rest of the button, and this is ignored).
void VerifyIconsMatch(const gfx::Image& bar_rendering,
                      const gfx::Image& model_icon) {}

ContextType;

class BrowserActionApiTest : public ExtensionApiTest {};

// Canvas tests rely on the harness producing pixel output in order to read back
// pixels from a canvas element. So we have to override the setup function.
// TODO(crbug.com/40698663): Investigate to see if these tests can be
// enabled for Service Worker-based extensions.
class BrowserActionApiCanvasTest : public BrowserActionApiTest {};

class BrowserActionApiTestWithContextType
    : public BrowserActionApiTest,
      public testing::WithParamInterface<ContextType> {};

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Basic) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Disable) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Enable) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Update) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, UpdateSvg) {}

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_F(BrowserActionApiCanvasTest, DynamicBrowserAction) {}

IN_PROC_BROWSER_TEST_F(BrowserActionApiCanvasTest, InvisibleIconBrowserAction) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
                       TabSpecificBrowserActionState) {}

// Test that calling chrome.browserAction.setIcon() can set the icon for
// extension.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, SetIcon) {}

// Test that calling chrome.browserAction.setPopup() can enable and change
// a popup.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, AddPopup) {}

// Test that calling chrome.browserAction.setPopup() can remove a popup.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, RemovePopup) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoBasic) {}

// TODO(crbug.com/338638098): leaks flakily on LSAN bots.
#if defined(LEAK_SANITIZER)
#define MAYBE_IncognitoUpdate
#else
#define MAYBE_IncognitoUpdate
#endif
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
                       MAYBE_IncognitoUpdate) {}

// Tests that events are dispatched to the correct profile for split mode
// extensions.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoSplit) {}

IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, CloseBackgroundPage) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
                       BadgeBackgroundColor) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Getters) {}

// Verify triggering browser action.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
                       TestTriggerBrowserAction) {}

IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
                       WithRectangularIcon) {}

// Verify video can enter and exit Picture-in_Picture when browser action icon
// is clicked.
IN_PROC_BROWSER_TEST_F(BrowserActionApiTest,
                       TestPictureInPictureOnBrowserActionIconClick) {}

}  // namespace
}  // namespace extensions