[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / apps / app_browsertest_util.h
blob6dc8da8fb70cbcb5d5fcdb0881b017361a5a9a65
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_
6 #define CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_
8 #include "apps/app_window.h"
9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "content/public/common/page_transition_types.h"
12 namespace base {
13 class CommandLine;
16 namespace content {
17 class WebContents;
20 class Browser;
22 namespace extensions {
23 class Extension;
25 class PlatformAppBrowserTest : public ExtensionApiTest {
26 public:
27 PlatformAppBrowserTest();
29 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
31 // Gets the first app window that is found for a given browser.
32 static apps::AppWindow* GetFirstAppWindowForBrowser(Browser* browser);
34 protected:
35 // Runs the app named |name| out of the platform_apps subdirectory. Waits
36 // until it is launched.
37 const Extension* LoadAndLaunchPlatformApp(const char* name);
39 // Installs the app named |name| out of the platform_apps subdirectory.
40 const Extension* InstallPlatformApp(const char* name);
42 // Installs and runs the app named |name| out of the platform_apps
43 // subdirectory. Waits until it is launched.
44 const Extension* InstallAndLaunchPlatformApp(const char* name);
46 // Launch the given platform app.
47 void LaunchPlatformApp(const Extension* extension);
49 // Gets the WebContents associated with the first app window that is found
50 // (most tests only deal with one platform app window, so this is good
51 // enough).
52 content::WebContents* GetFirstAppWindowWebContents();
54 // Gets the first app window that is found (most tests only deal with one
55 // platform app window, so this is good enough).
56 apps::AppWindow* GetFirstAppWindow();
58 // Gets the first app window for an app.
59 apps::AppWindow* GetFirstAppWindowForApp(const std::string& app_id);
61 // Runs chrome.windows.getAll for the given extension and returns the number
62 // of windows that the function returns.
63 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
65 // Runs chrome.windows.get(|window_id|) for the the given extension and
66 // returns whether or not a window was found.
67 bool RunGetWindowFunctionForExtension(int window_id,
68 const Extension* extension);
70 // Returns the number of app windows.
71 size_t GetAppWindowCount();
73 // Returns the number of app windows for a specific app.
74 size_t GetAppWindowCountForApp(const std::string& app_id);
76 // The command line already has an argument on it - about:blank, which
77 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
78 // launch tests we need to clear this.
79 void ClearCommandLineArgs();
81 // Sets up the command line for running platform apps.
82 void SetCommandLineArg(const std::string& test_file);
84 // Creates an empty app window for |extension|.
85 apps::AppWindow* CreateAppWindow(const Extension* extension);
87 apps::AppWindow* CreateAppWindowFromParams(
88 const Extension* extension,
89 const apps::AppWindow::CreateParams& params);
91 // Closes |window| and waits until it's gone.
92 void CloseAppWindow(apps::AppWindow* window);
94 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
95 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
96 apps::AppWindow* window,
97 const gfx::Rect& cached_bounds,
98 const gfx::Rect& cached_screen_bounds,
99 const gfx::Rect& current_screen_bounds,
100 const gfx::Size& minimum_size,
101 gfx::Rect* bounds);
103 // Load a simple test app and create a window. The window must be closed by
104 // the caller in order to terminate the test - use CloseAppWindow().
105 // |window_create_options| are the options that will be passed to
106 // chrome.app.window.create() in the test app.
107 apps::AppWindow* CreateTestAppWindow(
108 const std::string& window_create_options);
111 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
112 public:
113 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
116 } // namespace extensions
118 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_