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

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

Issue 1173753003: [Media Router] Implement JoinRoute + update CreateRoute API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/create_session_request_unittest.cc
diff --git a/chrome/browser/media/router/create_session_request_unittest.cc b/chrome/browser/media/router/create_session_request_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f25e855667220de87de966c7a1da624d6b2787d
--- /dev/null
+++ b/chrome/browser/media/router/create_session_request_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "chrome/browser/media/router/create_session_request.h"
+#include "chrome/browser/media/router/media_source_helper.h"
+#include "content/public/browser/presentation_service_delegate.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media_router {
+
+namespace {
+
+const char kPresentationUrl[] = "http://fooUrl";
+const char kPresentationId[] = "presentationId";
+
+} // namespace
+
+class CreateSessionRequestTest : public ::testing::Test {
+ public:
+ CreateSessionRequestTest() : success_cb_invoked_(false) {}
+ ~CreateSessionRequestTest() override {}
+
+ void OnSuccess(const content::PresentationSessionInfo& expected_info,
+ const content::PresentationSessionInfo& actual_info) {
+ success_cb_invoked_ = true;
+ EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url);
+ EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id);
+ }
+
+ void FailOnError(const content::PresentationError& error) {
+ FAIL() << "Should not have been called.";
+ }
+
+ bool success_cb_invoked_;
+};
+
+// Test that the object's getters match the constructor parameters.
+TEST_F(CreateSessionRequestTest, Getters) {
+ GURL frame_url("http://frameUrl");
+
+ content::PresentationSessionInfo session_info(kPresentationUrl,
+ kPresentationId);
+
+ CreateSessionRequest context(
+ kPresentationUrl, kPresentationId, frame_url,
+ CreateSessionRequest::PresentationSessionSuccessCallback(),
+ CreateSessionRequest::PresentationSessionErrorCallback());
+ EXPECT_TRUE(MediaSourceForPresentationUrl(kPresentationUrl)
+ .Equals(context.GetMediaSource()));
+ EXPECT_EQ(frame_url, context.frame_url());
+ content::PresentationSessionInfo actual_session_info(
+ context.presentation_info());
+ EXPECT_EQ(kPresentationUrl, actual_session_info.presentation_url);
+ EXPECT_EQ(kPresentationId, actual_session_info.presentation_id);
+}
+
+TEST_F(CreateSessionRequestTest, Callbacks) {
mark a. foltz 2015/06/10 23:18:51 Would like to see test cases that exercise both th
imcheng (use chromium acct) 2015/06/11 22:49:12 Done. Added a test case where error callback is in
+ GURL frame_url("http://frameUrl");
+ content::PresentationSessionInfo session_info(kPresentationUrl,
+ kPresentationId);
+ CreateSessionRequest context(
+ kPresentationUrl, kPresentationId, frame_url,
+ base::Bind(&CreateSessionRequestTest::OnSuccess, base::Unretained(this),
+ session_info),
+ base::Bind(&CreateSessionRequestTest::FailOnError,
+ base::Unretained(this)));
+ context.MaybeInvokeSuccessCallback();
+ // No-op since success callback is already invoked.
+ context.MaybeInvokeErrorCallback(content::PresentationError(
+ content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, "Error message"));
+ EXPECT_TRUE(success_cb_invoked_);
+}
+
+} // namespace media_router
« no previous file with comments | « no previous file | chrome/browser/media/router/media_router.h » ('j') | chrome/browser/media/router/media_router.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698