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

Side by Side Diff: talk/media/base/streamparams_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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
« no previous file with comments | « talk/media/base/streamparams.cc ('k') | talk/media/base/testutils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 11 matching lines...) Expand all
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/media/base/streamparams.h" 28 #include "talk/media/base/streamparams.h"
29 #include "talk/media/base/testutils.h" 29 #include "talk/media/base/testutils.h"
30 #include "webrtc/base/gunit.h" 30 #include "webrtc/base/gunit.h"
31 31
32 static const uint32 kSsrcs1[] = {1}; 32 static const uint32_t kSsrcs1[] = {1};
33 static const uint32 kSsrcs2[] = {1, 2}; 33 static const uint32_t kSsrcs2[] = {1, 2};
34 static const uint32 kSsrcs3[] = {1, 2, 3}; 34 static const uint32_t kSsrcs3[] = {1, 2, 3};
35 static const uint32 kRtxSsrcs3[] = {4, 5, 6}; 35 static const uint32_t kRtxSsrcs3[] = {4, 5, 6};
36 36
37 static cricket::StreamParams CreateStreamParamsWithSsrcGroup( 37 static cricket::StreamParams CreateStreamParamsWithSsrcGroup(
38 const std::string& semantics, const uint32 ssrcs_in[], size_t len) { 38 const std::string& semantics,
39 const uint32_t ssrcs_in[],
40 size_t len) {
39 cricket::StreamParams stream; 41 cricket::StreamParams stream;
40 std::vector<uint32> ssrcs(ssrcs_in, ssrcs_in + len); 42 std::vector<uint32_t> ssrcs(ssrcs_in, ssrcs_in + len);
41 cricket::SsrcGroup sg(semantics, ssrcs); 43 cricket::SsrcGroup sg(semantics, ssrcs);
42 stream.ssrcs = ssrcs; 44 stream.ssrcs = ssrcs;
43 stream.ssrc_groups.push_back(sg); 45 stream.ssrc_groups.push_back(sg);
44 return stream; 46 return stream;
45 } 47 }
46 48
47 TEST(SsrcGroup, EqualNotEqual) { 49 TEST(SsrcGroup, EqualNotEqual) {
48 cricket::SsrcGroup ssrc_groups[] = { 50 cricket::SsrcGroup ssrc_groups[] = {
49 cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs1)), 51 cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs1)),
50 cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs2)), 52 cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs2)),
(...skipping 19 matching lines...) Expand all
70 cricket::SsrcGroup sg3("abc", MAKE_VECTOR(kSsrcs1)); 72 cricket::SsrcGroup sg3("abc", MAKE_VECTOR(kSsrcs1));
71 EXPECT_FALSE(sg3.has_semantics("ABC")); 73 EXPECT_FALSE(sg3.has_semantics("ABC"));
72 } 74 }
73 75
74 TEST(SsrcGroup, ToString) { 76 TEST(SsrcGroup, ToString) {
75 cricket::SsrcGroup sg1("ABC", MAKE_VECTOR(kSsrcs1)); 77 cricket::SsrcGroup sg1("ABC", MAKE_VECTOR(kSsrcs1));
76 EXPECT_STREQ("{semantics:ABC;ssrcs:[1]}", sg1.ToString().c_str()); 78 EXPECT_STREQ("{semantics:ABC;ssrcs:[1]}", sg1.ToString().c_str());
77 } 79 }
78 80
79 TEST(StreamParams, CreateLegacy) { 81 TEST(StreamParams, CreateLegacy) {
80 const uint32 ssrc = 7; 82 const uint32_t ssrc = 7;
81 cricket::StreamParams one_sp = cricket::StreamParams::CreateLegacy(ssrc); 83 cricket::StreamParams one_sp = cricket::StreamParams::CreateLegacy(ssrc);
82 EXPECT_EQ(1U, one_sp.ssrcs.size()); 84 EXPECT_EQ(1U, one_sp.ssrcs.size());
83 EXPECT_EQ(ssrc, one_sp.first_ssrc()); 85 EXPECT_EQ(ssrc, one_sp.first_ssrc());
84 EXPECT_TRUE(one_sp.has_ssrcs()); 86 EXPECT_TRUE(one_sp.has_ssrcs());
85 EXPECT_TRUE(one_sp.has_ssrc(ssrc)); 87 EXPECT_TRUE(one_sp.has_ssrc(ssrc));
86 EXPECT_FALSE(one_sp.has_ssrc(ssrc+1)); 88 EXPECT_FALSE(one_sp.has_ssrc(ssrc+1));
87 EXPECT_FALSE(one_sp.has_ssrc_groups()); 89 EXPECT_FALSE(one_sp.has_ssrc_groups());
88 EXPECT_EQ(0U, one_sp.ssrc_groups.size()); 90 EXPECT_EQ(0U, one_sp.ssrc_groups.size());
89 } 91 }
90 92
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 127
126 for (size_t i = 0; i < ARRAY_SIZE(sps); ++i) { 128 for (size_t i = 0; i < ARRAY_SIZE(sps); ++i) {
127 for (size_t j = 0; j < ARRAY_SIZE(sps); ++j) { 129 for (size_t j = 0; j < ARRAY_SIZE(sps); ++j) {
128 EXPECT_EQ((sps[i] == sps[j]), (i == j)); 130 EXPECT_EQ((sps[i] == sps[j]), (i == j));
129 EXPECT_EQ((sps[i] != sps[j]), (i != j)); 131 EXPECT_EQ((sps[i] != sps[j]), (i != j));
130 } 132 }
131 } 133 }
132 } 134 }
133 135
134 TEST(StreamParams, FidFunctions) { 136 TEST(StreamParams, FidFunctions) {
135 uint32 fid_ssrc; 137 uint32_t fid_ssrc;
136 138
137 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1); 139 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1);
138 EXPECT_FALSE(sp.AddFidSsrc(10, 20)); 140 EXPECT_FALSE(sp.AddFidSsrc(10, 20));
139 EXPECT_TRUE(sp.AddFidSsrc(1, 2)); 141 EXPECT_TRUE(sp.AddFidSsrc(1, 2));
140 EXPECT_TRUE(sp.GetFidSsrc(1, &fid_ssrc)); 142 EXPECT_TRUE(sp.GetFidSsrc(1, &fid_ssrc));
141 EXPECT_EQ(2u, fid_ssrc); 143 EXPECT_EQ(2u, fid_ssrc);
142 EXPECT_FALSE(sp.GetFidSsrc(15, &fid_ssrc)); 144 EXPECT_FALSE(sp.GetFidSsrc(15, &fid_ssrc));
143 145
144 sp.add_ssrc(20); 146 sp.add_ssrc(20);
145 sp.AddFidSsrc(20, 30); 147 sp.AddFidSsrc(20, 30);
146 EXPECT_TRUE(sp.GetFidSsrc(20, &fid_ssrc)); 148 EXPECT_TRUE(sp.GetFidSsrc(20, &fid_ssrc));
147 EXPECT_EQ(30u, fid_ssrc); 149 EXPECT_EQ(30u, fid_ssrc);
148 150
149 // Manually create SsrcGroup to test bounds-checking 151 // Manually create SsrcGroup to test bounds-checking
150 // in GetSecondarySsrc. We construct an invalid StreamParams 152 // in GetSecondarySsrc. We construct an invalid StreamParams
151 // for this. 153 // for this.
152 std::vector<uint32> fid_vector; 154 std::vector<uint32_t> fid_vector;
153 fid_vector.push_back(13); 155 fid_vector.push_back(13);
154 cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics, 156 cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics,
155 fid_vector); 157 fid_vector);
156 cricket::StreamParams sp_invalid; 158 cricket::StreamParams sp_invalid;
157 sp_invalid.add_ssrc(13); 159 sp_invalid.add_ssrc(13);
158 sp_invalid.ssrc_groups.push_back(invalid_fid_group); 160 sp_invalid.ssrc_groups.push_back(invalid_fid_group);
159 EXPECT_FALSE(sp_invalid.GetFidSsrc(13, &fid_ssrc)); 161 EXPECT_FALSE(sp_invalid.GetFidSsrc(13, &fid_ssrc));
160 } 162 }
161 163
162 TEST(StreamParams, GetPrimaryAndFidSsrcs) { 164 TEST(StreamParams, GetPrimaryAndFidSsrcs) {
163 cricket::StreamParams sp; 165 cricket::StreamParams sp;
164 sp.ssrcs.push_back(1); 166 sp.ssrcs.push_back(1);
165 sp.ssrcs.push_back(2); 167 sp.ssrcs.push_back(2);
166 sp.ssrcs.push_back(3); 168 sp.ssrcs.push_back(3);
167 169
168 std::vector<uint32> primary_ssrcs; 170 std::vector<uint32_t> primary_ssrcs;
169 sp.GetPrimarySsrcs(&primary_ssrcs); 171 sp.GetPrimarySsrcs(&primary_ssrcs);
170 std::vector<uint32> fid_ssrcs; 172 std::vector<uint32_t> fid_ssrcs;
171 sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs); 173 sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs);
172 ASSERT_EQ(1u, primary_ssrcs.size()); 174 ASSERT_EQ(1u, primary_ssrcs.size());
173 EXPECT_EQ(1u, primary_ssrcs[0]); 175 EXPECT_EQ(1u, primary_ssrcs[0]);
174 ASSERT_EQ(0u, fid_ssrcs.size()); 176 ASSERT_EQ(0u, fid_ssrcs.size());
175 177
176 sp.ssrc_groups.push_back( 178 sp.ssrc_groups.push_back(
177 cricket::SsrcGroup(cricket::kSimSsrcGroupSemantics, sp.ssrcs)); 179 cricket::SsrcGroup(cricket::kSimSsrcGroupSemantics, sp.ssrcs));
178 sp.AddFidSsrc(1, 10); 180 sp.AddFidSsrc(1, 10);
179 sp.AddFidSsrc(2, 20); 181 sp.AddFidSsrc(2, 20);
180 182
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // stream2 has invalid fid-group (no primary). 267 // stream2 has invalid fid-group (no primary).
266 cricket::StreamParams stream2; 268 cricket::StreamParams stream2;
267 stream2.add_ssrc(13); 269 stream2.add_ssrc(13);
268 EXPECT_TRUE(stream2.AddFidSsrc(13, 14)); 270 EXPECT_TRUE(stream2.AddFidSsrc(13, 14));
269 std::remove(stream2.ssrcs.begin(), stream2.ssrcs.end(), 13); 271 std::remove(stream2.ssrcs.begin(), stream2.ssrcs.end(), 13);
270 EXPECT_FALSE(cricket::IsSimulcastStream(stream2)); 272 EXPECT_FALSE(cricket::IsSimulcastStream(stream2));
271 273
272 // stream3 has two SIM groups. 274 // stream3 has two SIM groups.
273 cricket::StreamParams stream3 = 275 cricket::StreamParams stream3 =
274 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2)); 276 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2));
275 std::vector<uint32> sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3); 277 std::vector<uint32_t> sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3);
276 cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, sim_ssrcs); 278 cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, sim_ssrcs);
277 for (size_t i = 0; i < sim_ssrcs.size(); i++) { 279 for (size_t i = 0; i < sim_ssrcs.size(); i++) {
278 stream3.add_ssrc(sim_ssrcs[i]); 280 stream3.add_ssrc(sim_ssrcs[i]);
279 } 281 }
280 stream3.ssrc_groups.push_back(sg); 282 stream3.ssrc_groups.push_back(sg);
281 EXPECT_FALSE(cricket::IsSimulcastStream(stream3)); 283 EXPECT_FALSE(cricket::IsSimulcastStream(stream3));
282 } 284 }
OLDNEW
« no previous file with comments | « talk/media/base/streamparams.cc ('k') | talk/media/base/testutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698