[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / chrome / test / media_router / media_router_e2e_browsertest.h
blob321c3c4f5545be9ced27962f9cb2dfb89a701ef0
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"
17 namespace media_router {
19 class MediaRouter;
21 class MediaRouterE2EBrowserTest : public MediaRouterBaseBrowserTest {
22 public:
23 MediaRouterE2EBrowserTest();
24 ~MediaRouterE2EBrowserTest() override;
26 protected:
27 // InProcessBrowserTest Overrides
28 void SetUpOnMainThread() override;
29 void TearDownOnMainThread() override;
31 // MediaRouterBaseBrowserTest Overrides
32 void ParseCommandLine() override;
34 // Callback from MediaRouter when a response to a media route request is
35 // received.
36 void OnRouteResponseReceived(scoped_ptr<MediaRoute> route,
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, const GURL& origin,
50 int tab_id);
52 // Stops the established media route and unregisters |observer_|.
53 // Note that the route may not be stopped immediately, as it makes an
54 // async call to the Media Route Provider.
55 // |observer_| and |route_id_| will be reset.
56 void StopMediaRoute();
58 std::string receiver() const { return receiver_; }
60 bool IsSinkDiscovered() const;
61 bool IsRouteCreated() const;
63 private:
64 std::string receiver_;
66 MediaRouter* media_router_;
67 scoped_ptr<TestMediaSinksObserver> observer_;
68 MediaRoute::Id route_id_;
71 } // namespace media_router
73 #endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_E2E_BROWSERTEST_H_