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

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: resolve code review comments from Derek Created 4 years, 1 month 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 ae7df101c08efc0fda7d0b69450f3c2ae0c2083d..a249394fdc6af9cb05e47c044cb853b71e659e51 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
+++ b/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
@@ -10,6 +10,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"
@@ -20,6 +22,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
+#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
@@ -62,6 +65,38 @@ 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) 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:
@@ -471,4 +506,31 @@ TEST_F(PresentationServiceDelegateImplTest, SinksObserverCantRegister) {
render_process_id, render_frame_id, &listener));
}
+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;
+ delegate_impl_->ConnectToOffscreenPresentation(render_process_id,
+ render_frame_id, session_info,
+ std::move(connection_ptr));
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698