Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / media_router / media_router_e2e_browsertest.h
blob17affe1b9d8b45b249a4e41c7e394acc9691e3d5
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_E2E_BROWSERTEST_H_
6 #define CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_E2E_BROWSERTEST_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/media/router/media_route.h"
12 #include "chrome/browser/media/router/media_router.h"
13 #include "chrome/test/media_router/media_router_base_browsertest.h"
14 #include "chrome/test/media_router/test_media_sinks_observer.h"
16 namespace media_router {
18 class MediaRouter;
20 class MediaRouterE2EBrowserTest : public MediaRouterBaseBrowserTest {
21 public:
22 MediaRouterE2EBrowserTest();
23 ~MediaRouterE2EBrowserTest() override;
25 protected:
26 // InProcessBrowserTest Overrides
27 void SetUpOnMainThread() override;
28 void TearDownOnMainThread() override;
30 // MediaRouterBaseBrowserTest Overrides
31 void ParseCommandLine() override;
33 // Callback from MediaRouter when a response to a media route request is
34 // received.
35 void OnRouteResponseReceived(const MediaRoute* route,
36 const std::string& presentation_id,
37 const std::string& error);
39 // Initializes |observer_| to listen for sinks compatible with |source|,
40 // finds sink with name matching receiver_, and establishes media
41 // route between the source and sink.
42 // |observer_| and |route_id_| will be initialized.
43 // |origin| is the URL of requestor's page.
44 // |tab_id| is the ID of the tab in which the request was made.
45 // |origin| and |tab_id| are used for enforcing same-origin and/or same-tab
46 // scope for JoinRoute() requests. (e.g., if enforced, the page
47 // requesting JoinRoute() must have the same origin as the page that requested
48 // CreateRoute()).
49 void CreateMediaRoute(const MediaSource& source,
50 const GURL& origin,
51 int tab_id);
53 // Stops the established media route and unregisters |observer_|.
54 // Note that the route may not be stopped immediately, as it makes an
55 // async call to the Media Route Provider.
56 // |observer_| and |route_id_| will be reset.
57 void StopMediaRoute();
59 std::string receiver() const { return receiver_; }
61 bool IsSinkDiscovered() const;
62 bool IsRouteCreated() const;
64 private:
65 std::string receiver_;
67 MediaRouter* media_router_;
68 scoped_ptr<TestMediaSinksObserver> observer_;
69 MediaRoute::Id route_id_;
72 } // namespace media_router
74 #endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_E2E_BROWSERTEST_H_