Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2500)

Unified Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: fix windows compile error Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
diff --git a/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc b/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
index 10686bc8463989089b0549cbd3d06851ac6ed4a8..d4543441792de518df4871e07f4a0209dce89d5a 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
+++ b/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
@@ -9,6 +9,8 @@
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
#include "chrome/browser/media/router/mock_screen_availability_listener.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
#include "chrome/browser/media/router/route_request_result.h"
#include "chrome/browser/media/router/test_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -21,6 +23,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/presentation_session.h"
#include "content/public/test/web_contents_tester.h"
+#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "url/origin.h"
@@ -66,6 +69,39 @@ class MockCreatePresentationConnnectionCallbacks {
void(const content::PresentationError& error));
};
+class MockOffscreenPresentationManager : public OffscreenPresentationManager {
+ public:
+ void RegisterOffscreenPresentationController(
+ const std::string& presentation_id,
+ const GURL& presentation_url,
+ const RenderFrameHostId& render_frame_id,
+ content::PresentationConnectionPtr controller,
+ content::PresentationConnectionRequest) override {
+ RegisterOffscreenPresentationController(presentation_id, presentation_url,
+ render_frame_id);
+ }
+
+ MOCK_METHOD3(RegisterOffscreenPresentationController,
+ void(const std::string& presentation_id,
+ const GURL& presentation_url,
+ const RenderFrameHostId& render_frame_id));
+ MOCK_METHOD2(UnregisterOffscreenPresentationController,
+ void(const std::string& presentation_id,
+ const RenderFrameHostId& render_frame_id));
+ MOCK_METHOD3(OnOffscreenPresentationReceiverCreated,
+ void(const std::string& presentation_id,
+ const GURL& presentation_url,
+ const content::ReceiverConnectionAvailableCallback&
+ receiver_callback));
+ MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated,
+ void(const std::string& presentation_id));
+};
+
+std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager(
+ content::BrowserContext* context) {
+ return base::MakeUnique<MockOffscreenPresentationManager>();
+}
+
class PresentationServiceDelegateImplTest
: public ChromeRenderViewHostTestHarness {
public:
@@ -449,6 +485,34 @@ TEST_F(PresentationServiceDelegateImplTest, SinksObserverCantRegister) {
main_frame_process_id_, main_frame_routing_id_, &listener1_));
}
+TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) {
+ content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
+ ASSERT_TRUE(main_frame);
+ int render_process_id = main_frame->GetProcess()->GetID();
+ int render_frame_id = main_frame->GetRoutingID();
+ std::string presentation_id = "presentation_id";
+ GURL presentation_url = GURL("http://www.example.com/presentation.html");
+ content::PresentationSessionInfo session_info(presentation_url,
+ presentation_id);
+
+ OffscreenPresentationManagerFactory::GetInstanceForTest()->SetTestingFactory(
+ profile(), &BuildMockOffscreenPresentationManager);
+ MockOffscreenPresentationManager* mock_offscreen_manager =
+ static_cast<MockOffscreenPresentationManager*>(
+ OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
+ profile()));
+ EXPECT_CALL(*mock_offscreen_manager,
+ RegisterOffscreenPresentationController(
+ presentation_id, presentation_url,
+ RenderFrameHostId(render_process_id, render_frame_id)));
+
+ content::PresentationConnectionPtr connection_ptr;
+ content::PresentationConnectionRequest connection_request;
+ delegate_impl_->ConnectToOffscreenPresentation(
+ render_process_id, render_frame_id, session_info,
+ std::move(connection_ptr), std::move(connection_request));
+}
+
#if !defined(OS_ANDROID)
TEST_F(PresentationServiceDelegateImplTest, AutoJoinRequest) {
GURL frame_url(kFrameUrl);

Powered by Google App Engine
This is Rietveld 408576698