#ifndef CHROME_BROWSER_APPS_PLATFORM_APPS_APP_BROWSERTEST_UTIL_H_
#define CHROME_BROWSER_APPS_PLATFORM_APPS_APP_BROWSERTEST_UTIL_H_
#include <stddef.h>
#include <memory>
#include <string>
#include "base/auto_reset.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/mixin_based_extension_apitest.h"
#include "extensions/browser/app_window/app_window.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "components/media_router/browser/test/mock_media_router.h"
#endif
namespace base {
class CommandLine;
}
namespace content {
class BrowserContext;
class WebContents;
}
class Browser;
class ExtensionTestMessageListener;
namespace extensions {
class Extension;
class PlatformAppBrowserTest : public MixinBasedExtensionApiTest {
public:
PlatformAppBrowserTest();
PlatformAppBrowserTest(const PlatformAppBrowserTest&) = delete;
PlatformAppBrowserTest& operator=(const PlatformAppBrowserTest&) = delete;
~PlatformAppBrowserTest() override;
void SetUpCommandLine(base::CommandLine* command_line) override;
void SetUpOnMainThread() override;
void TearDownOnMainThread() override;
static AppWindow* GetFirstAppWindowForBrowser(Browser* browser);
protected:
const Extension* LoadAndLaunchPlatformApp(
const char* name,
ExtensionTestMessageListener* listener);
const Extension* LoadAndLaunchPlatformApp(const char* name,
const std::string& message);
const Extension* InstallPlatformApp(const char* name);
const Extension* InstallHostedApp();
const Extension* InstallAndLaunchPlatformApp(const char* name);
virtual void LaunchPlatformApp(const Extension* extension);
virtual void LaunchHostedApp(const Extension* extension);
content::WebContents* GetFirstAppWindowWebContents();
AppWindow* GetFirstAppWindow();
AppWindow* GetFirstAppWindowForApp(const std::string& app_id);
size_t RunGetWindowsFunctionForExtension(const Extension* extension);
bool RunGetWindowFunctionForExtension(int window_id,
const Extension* extension);
size_t GetAppWindowCount();
size_t GetAppWindowCountForApp(const std::string& app_id);
AppWindow* CreateAppWindow(content::BrowserContext* context,
const Extension* extension);
AppWindow* CreateAppWindowFromParams(content::BrowserContext* context,
const Extension* extension,
const AppWindow::CreateParams& params);
void CloseAppWindow(AppWindow* window);
void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
AppWindow* window,
const gfx::Rect& cached_bounds,
const gfx::Rect& cached_screen_bounds,
const gfx::Rect& current_screen_bounds,
const gfx::Size& minimum_size,
gfx::Rect* bounds);
AppWindow* CreateTestAppWindow(const std::string& window_create_options);
NativeAppWindow* GetNativeAppWindowForAppWindow(AppWindow* window);
private:
#if BUILDFLAG(IS_CHROMEOS)
std::unique_ptr<media_router::MockMediaRouter> media_router_;
#endif
base::AutoReset<bool> enable_chrome_apps_;
};
class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override;
};
}
#endif