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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "base/bind.h"
6 #include "chrome/browser/media/router/create_session_request.h"
7 #include "chrome/browser/media/router/media_source_helper.h"
8 #include "content/public/browser/presentation_service_delegate.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace media_router {
12
13 namespace {
14
15 const char kPresentationUrl[] = "http://fooUrl";
16 const char kPresentationId[] = "presentationId";
17
18 } // namespace
19
20 class CreateSessionRequestTest : public ::testing::Test {
21 public:
22 CreateSessionRequestTest() : success_cb_invoked_(false) {}
23 ~CreateSessionRequestTest() override {}
24
25 void OnSuccess(const content::PresentationSessionInfo& expected_info,
26 const content::PresentationSessionInfo& actual_info) {
27 success_cb_invoked_ = true;
28 EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url);
29 EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id);
30 }
31
32 void FailOnError(const content::PresentationError& error) {
33 FAIL() << "Should not have been called.";
34 }
35
36 bool success_cb_invoked_;
37 };
38
39 // Test that the object's getters match the constructor parameters.
40 TEST_F(CreateSessionRequestTest, Getters) {
41 GURL frame_url("http://frameUrl");
42
43 content::PresentationSessionInfo session_info(kPresentationUrl,
44 kPresentationId);
45
46 CreateSessionRequest context(
47 kPresentationUrl, kPresentationId, frame_url,
48 CreateSessionRequest::PresentationSessionSuccessCallback(),
49 CreateSessionRequest::PresentationSessionErrorCallback());
50 EXPECT_TRUE(MediaSourceForPresentationUrl(kPresentationUrl)
51 .Equals(context.GetMediaSource()));
52 EXPECT_EQ(frame_url, context.frame_url());
53 content::PresentationSessionInfo actual_session_info(
54 context.presentation_info());
55 EXPECT_EQ(kPresentationUrl, actual_session_info.presentation_url);
56 EXPECT_EQ(kPresentationId, actual_session_info.presentation_id);
57 }
58
59 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
60 GURL frame_url("http://frameUrl");
61 content::PresentationSessionInfo session_info(kPresentationUrl,
62 kPresentationId);
63 CreateSessionRequest context(
64 kPresentationUrl, kPresentationId, frame_url,
65 base::Bind(&CreateSessionRequestTest::OnSuccess, base::Unretained(this),
66 session_info),
67 base::Bind(&CreateSessionRequestTest::FailOnError,
68 base::Unretained(this)));
69 context.MaybeInvokeSuccessCallback();
70 // No-op since success callback is already invoked.
71 context.MaybeInvokeErrorCallback(content::PresentationError(
72 content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, "Error message"));
73 EXPECT_TRUE(success_cb_invoked_);
74 }
75
76 } // namespace media_router
OLDNEW
« 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