| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/base/rtccertificategenerator.h" | 11 #include "webrtc/base/rtccertificategenerator.h" |
| 12 | 12 |
| 13 #include <memory> |
| 14 |
| 13 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
| 15 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 16 #include "webrtc/base/optional.h" | 18 #include "webrtc/base/optional.h" |
| 17 #include "webrtc/base/scoped_ptr.h" | |
| 18 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
| 19 | 20 |
| 20 namespace rtc { | 21 namespace rtc { |
| 21 | 22 |
| 22 class RTCCertificateGeneratorFixture : public RTCCertificateGeneratorCallback { | 23 class RTCCertificateGeneratorFixture : public RTCCertificateGeneratorCallback { |
| 23 public: | 24 public: |
| 24 RTCCertificateGeneratorFixture() | 25 RTCCertificateGeneratorFixture() |
| 25 : signaling_thread_(Thread::Current()), | 26 : signaling_thread_(Thread::Current()), |
| 26 worker_thread_(new Thread()), | 27 worker_thread_(new Thread()), |
| 27 generate_async_completed_(false) { | 28 generate_async_completed_(false) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 52 if (generate_async_completed_) { | 53 if (generate_async_completed_) { |
| 53 // Reset flag so that future generation requests are not considered done. | 54 // Reset flag so that future generation requests are not considered done. |
| 54 generate_async_completed_ = false; | 55 generate_async_completed_ = false; |
| 55 return true; | 56 return true; |
| 56 } | 57 } |
| 57 return false; | 58 return false; |
| 58 } | 59 } |
| 59 | 60 |
| 60 protected: | 61 protected: |
| 61 Thread* const signaling_thread_; | 62 Thread* const signaling_thread_; |
| 62 scoped_ptr<Thread> worker_thread_; | 63 std::unique_ptr<Thread> worker_thread_; |
| 63 scoped_ptr<RTCCertificateGenerator> generator_; | 64 std::unique_ptr<RTCCertificateGenerator> generator_; |
| 64 scoped_refptr<RTCCertificate> certificate_; | 65 scoped_refptr<RTCCertificate> certificate_; |
| 65 bool generate_async_completed_; | 66 bool generate_async_completed_; |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 class RTCCertificateGeneratorTest | 69 class RTCCertificateGeneratorTest |
| 69 : public testing::Test { | 70 : public testing::Test { |
| 70 public: | 71 public: |
| 71 RTCCertificateGeneratorTest() | 72 RTCCertificateGeneratorTest() |
| 72 : fixture_(new RefCountedObject<RTCCertificateGeneratorFixture>()) {} | 73 : fixture_(new RefCountedObject<RTCCertificateGeneratorFixture>()) {} |
| 73 ~RTCCertificateGeneratorTest() {} | 74 ~RTCCertificateGeneratorTest() {} |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 143 |
| 143 fixture_->generator()->GenerateCertificateAsync( | 144 fixture_->generator()->GenerateCertificateAsync( |
| 144 invalid_params, | 145 invalid_params, |
| 145 Optional<uint64_t>(), | 146 Optional<uint64_t>(), |
| 146 fixture_); | 147 fixture_); |
| 147 EXPECT_TRUE_WAIT(fixture_->GenerateAsyncCompleted(), kGenerationTimeoutMs); | 148 EXPECT_TRUE_WAIT(fixture_->GenerateAsyncCompleted(), kGenerationTimeoutMs); |
| 148 EXPECT_FALSE(fixture_->certificate()); | 149 EXPECT_FALSE(fixture_->certificate()); |
| 149 } | 150 } |
| 150 | 151 |
| 151 } // namespace rtc | 152 } // namespace rtc |
| OLD | NEW |