Files
platform-external-webrtc/webrtc/base/helpers_unittest.cc
deadbeef 5def7b9fde Revert of Adding the ability to create an RtpSender without a track. (patchset #3 id:300001 of https://codereview.webrtc.org/1413983004/ )
Reason for revert:
Still breaking CallAndModifyStream. Chromium CL intended to fix it (https://codereview.chromium.org/1435713002/) wasn't sufficient, because I forgot to call addStream/removeStream on the second connection.

Original issue's description:
> Reland of Adding the ability to create an RtpSender without a track. (patchset #1 id:1 of https://codereview.webrtc.org/1426443007/ )
>
> Reason for revert:
> Relanding, after changing the expectations of WebRtcBrowserTest.CallAndModifyStream.
>
> Original issue's description:
> > Revert of Adding the ability to create an RtpSender without a track. (patchset #8 id:140001 of https://codereview.webrtc.org/1413713003/ )
> >
> > Reason for revert:
> > Causing a compiler warning, and causing WebRtcBrowserTest.CallAndModifyStream to fail.
> >
> > Original issue's description:
> > > Adding the ability to create an RtpSender without a track.
> > >
> > > This CL also changes AddStream to immediately create a sender, rather
> > > than waiting until the track is seen in SDP. And the PeerConnection now
> > > builds the list of "send streams" from the list of senders, rather than
> > > the collection of local media streams.
> > >
> > > Committed: https://crrev.com/ac9d92ccbe2b29590c53f702e11dc625820480d5
> > > Cr-Commit-Position: refs/heads/master@{#10414}
> >
> > TBR=pthatcher@webrtc.org,pthatcher@chromium.org
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> >
> > Committed: https://crrev.com/8f46c63f6f764254892f4111b54aa1cc8f32eeeb
> > Cr-Commit-Position: refs/heads/master@{#10417}
>
> TBR=pthatcher@webrtc.org,pthatcher@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://crrev.com/6834fa10f142bf5e2275142acb834898911d09ae
> Cr-Commit-Position: refs/heads/master@{#10730}

TBR=pthatcher@webrtc.org,pthatcher@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.webrtc.org/1460323002

Cr-Commit-Position: refs/heads/master@{#10732}
2015-11-20 19:43:27 +00:00

70 lines
1.9 KiB
C++

/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <string>
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/ssladapter.h"
namespace rtc {
class RandomTest : public testing::Test {};
TEST_F(RandomTest, TestCreateRandomId) {
CreateRandomId();
}
TEST_F(RandomTest, TestCreateRandomDouble) {
for (int i = 0; i < 100; ++i) {
double r = CreateRandomDouble();
EXPECT_GE(r, 0.0);
EXPECT_LT(r, 1.0);
}
}
TEST_F(RandomTest, TestCreateNonZeroRandomId) {
EXPECT_NE(0U, CreateRandomNonZeroId());
}
TEST_F(RandomTest, TestCreateRandomString) {
std::string random = CreateRandomString(256);
EXPECT_EQ(256U, random.size());
std::string random2;
EXPECT_TRUE(CreateRandomString(256, &random2));
EXPECT_NE(random, random2);
EXPECT_EQ(256U, random2.size());
}
TEST_F(RandomTest, TestCreateRandomForTest) {
// Make sure we get the output we expect.
SetRandomTestMode(true);
EXPECT_EQ(2154761789U, CreateRandomId());
EXPECT_EQ("h0ISP4S5SJKH/9EY", CreateRandomString(16));
// Reset and make sure we get the same output.
SetRandomTestMode(true);
EXPECT_EQ(2154761789U, CreateRandomId());
EXPECT_EQ("h0ISP4S5SJKH/9EY", CreateRandomString(16));
// Test different character sets.
SetRandomTestMode(true);
std::string str;
EXPECT_TRUE(CreateRandomString(16, "a", &str));
EXPECT_EQ("aaaaaaaaaaaaaaaa", str);
EXPECT_TRUE(CreateRandomString(16, "abc", &str));
EXPECT_EQ("acbccaaaabbaacbb", str);
// Turn off test mode for other tests.
SetRandomTestMode(false);
}
} // namespace rtc