Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / media_router / media_router_integration_browsertest.h
blob91c3f5d22d4cbef34abc7f4c1a5e232a87439f50
1 // Copyright 2015 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_TEST_MEDIA_ROUTER_MEDIA_ROUTER_INTEGRATION_BROWSERTEST_H_
6 #define CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_INTEGRATION_BROWSERTEST_H_
8 #include <string>
10 #include "base/debug/stack_trace.h"
11 #include "base/files/file_path.h"
12 #include "chrome/browser/ui/toolbar/media_router_action.h"
13 #include "chrome/test/media_router/media_router_base_browsertest.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/test_navigation_observer.h"
18 namespace media_router {
20 class MediaRouter;
22 class MediaRouterIntegrationBrowserTest : public MediaRouterBaseBrowserTest {
23 public:
24 MediaRouterIntegrationBrowserTest();
25 ~MediaRouterIntegrationBrowserTest() override;
27 protected:
28 // InProcessBrowserTest Overrides
29 void TearDownOnMainThread() override;
31 // Simulate user action to choose one sink in the popup dialog.
32 // |web_contents|: The web contents of the test page which invokes the popup
33 // dialog.
34 // |sink_id|: The sink id.
35 // |current_route|: The JSON string which represents current route.
36 void ChooseSink(content::WebContents* web_contents,
37 const std::string& sink_id, const std::string& current_route);
39 // Execute javascript and check the return value.
40 static void ExecuteJavaScriptAPI(content::WebContents* web_contents,
41 const std::string& script);
43 static int ExecuteScriptAndExtractInt(
44 const content::ToRenderFrameHost& adapter,
45 const std::string& script);
47 static std::string ExecuteScriptAndExtractString(
48 const content::ToRenderFrameHost& adapter, const std::string& script);
50 // Get the chrome modal dialog.
51 // |web_contents|: The web contents of the test page which invokes the popup
52 // dialog.
53 content::WebContents* GetMRDialog(content::WebContents* web_contents);
55 void OpenTestPage(base::FilePath::StringPieceType file);
56 void OpenTestPageInNewTab(base::FilePath::StringPieceType file);
58 void SetTestData(base::FilePath::StringPieceType test_data_file);
60 // Start session and wait until the pop dialog shows up.
61 // |web_contents|: The web contents of the test page which invokes the popup
62 // dialog.
63 void StartSession(content::WebContents* web_contents);
65 // Open the chrome modal dialog.
66 // |web_contents|: The web contents of the test page which invokes the popup
67 // dialog.
68 content::WebContents* OpenMRDialog(content::WebContents* web_contents);
70 bool IsRouteCreatedOnUI();
72 // Wait for the route to show up in the UI with a timeout. Fails if the
73 // route did not show up before the timeout.
74 void WaitUntilRouteCreated();
76 private:
77 // Get the full path of the resource file.
78 // |relative_path|: The relative path to
79 // <chromium src>/out/<build config>/media_router/
80 // browser_test_resources/
81 base::FilePath GetResourceFile(
82 base::FilePath::StringPieceType relative_path) const;
84 scoped_ptr<content::TestNavigationObserver> test_navigation_observer_;
87 } // namespace media_router
89 #endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_INTEGRATION_BROWSERTEST_H_