| Index: content/browser/media/dtls_identity_store_unittest.cc
|
| diff --git a/content/browser/media/dtls_identity_store_unittest.cc b/content/browser/media/dtls_identity_store_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5950c688c89ab22296cd921f39c1869c19f30b50
|
| --- /dev/null
|
| +++ b/content/browser/media/dtls_identity_store_unittest.cc
|
| @@ -0,0 +1,60 @@
|
| +// Copyright (c) 2013 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/memory/scoped_ptr.h"
|
| +#include "base/message_loop.h"
|
| +#include "base/threading/sequenced_worker_pool.h"
|
| +#include "content/browser/media/dtls_identity_store.h"
|
| +#include "content/public/test/test_browser_thread.h"
|
| +#include "googleurl/src/gurl.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +
|
| +namespace content {
|
| +namespace {
|
| +
|
| +class DTLSIdentityStoreTest : public testing::Test {
|
| + public:
|
| + DTLSIdentityStoreTest() :
|
| + ui_thread_(BrowserThread::UI, &message_loop_),
|
| + sequenced_worker_pool_(new base::SequencedWorkerPool(
|
| + 3, "ServerBoundCertServiceTest")),
|
| + completed_(false) {}
|
| +
|
| + virtual ~DTLSIdentityStoreTest() {
|
| + sequenced_worker_pool_->Shutdown();
|
| + }
|
| +
|
| + void OnGetOrGenerateCompleted(const std::string& certificate,
|
| + const std::string& private_key) {
|
| + ASSERT_NE("", certificate);
|
| + ASSERT_NE("", private_key);
|
| + completed_ = true;
|
| + }
|
| +
|
| + protected:
|
| + virtual void SetUp() {
|
| + completed_ = false;
|
| + }
|
| +
|
| + base::MessageLoopForUI message_loop_;
|
| + TestBrowserThread ui_thread_;
|
| + scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_;
|
| + bool completed_;
|
| +};
|
| +
|
| +TEST_F(DTLSIdentityStoreTest, GetOrGenerateIdentity) {
|
| + DTLSIdentityStore* store = new DTLSIdentityStore(sequenced_worker_pool_);
|
| + store->GetOrGenerateIdentity(
|
| + GURL("http://google.com"), "a", "b",
|
| + base::Bind(&DTLSIdentityStoreTest::OnGetOrGenerateCompleted,
|
| + base::Unretained(this)));
|
| + sequenced_worker_pool_->FlushForTesting();
|
| + message_loop_.RunUntilIdle();
|
| +
|
| + EXPECT_EQ(true, completed_);
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace content
|
|
|