OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" | 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
11 #include "chrome/browser/local_discovery/privet_http.h" | 12 #include "chrome/browser/local_discovery/privet_http.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
14 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
15 #include "crypto/hmac.h" | 16 #include "crypto/hmac.h" |
16 #include "crypto/p224_spake.h" | 17 #include "crypto/p224_spake.h" |
17 #include "net/url_request/test_url_fetcher_factory.h" | 18 #include "net/url_request/test_url_fetcher_factory.h" |
18 #include "net/url_request/url_request_test_util.h" | 19 #include "net/url_request/url_request_test_util.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 MOCK_METHOD1(OnPairingStarted, void(Result)); | 67 MOCK_METHOD1(OnPairingStarted, void(Result)); |
67 MOCK_METHOD1(OnCodeConfirmed, void(Result)); | 68 MOCK_METHOD1(OnCodeConfirmed, void(Result)); |
68 MOCK_METHOD2(OnMessageSend, void(Result, const base::DictionaryValue&)); | 69 MOCK_METHOD2(OnMessageSend, void(Result, const base::DictionaryValue&)); |
69 MOCK_METHOD1(OnPostData, void(const base::DictionaryValue&)); | 70 MOCK_METHOD1(OnPostData, void(const base::DictionaryValue&)); |
70 | 71 |
71 protected: | 72 protected: |
72 void SetUp() override { | 73 void SetUp() override { |
73 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 74 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
74 switches::kEnablePrivetV3); | 75 switches::kEnablePrivetV3); |
75 | 76 |
76 scoped_refptr<net::TestURLRequestContextGetter> context_getter = | 77 scoped_refptr<PrivetV3ContextGetter> context_getter = |
77 new net::TestURLRequestContextGetter( | 78 new PrivetV3ContextGetter(base::ThreadTaskRunnerHandle::Get()); |
78 content::BrowserThread::GetMessageLoopProxyForThread( | |
79 content::BrowserThread::IO)); | |
80 | 79 |
81 session_.reset( | 80 session_.reset( |
82 new PrivetV3Session(context_getter, net::HostPortPair("host", 80))); | 81 new PrivetV3Session(context_getter, net::HostPortPair("host", 80))); |
83 | 82 |
84 session_->on_post_data_ = | 83 session_->on_post_data_ = |
85 base::Bind(&PrivetV3SessionTest::OnPostData, base::Unretained(this)); | 84 base::Bind(&PrivetV3SessionTest::OnPostData, base::Unretained(this)); |
86 } | 85 } |
87 | 86 |
88 content::TestBrowserThreadBundle thread_bundle_; | 87 content::TestBrowserThreadBundle thread_bundle_; |
89 net::FakeURLFetcherFactory fetcher_factory_; | 88 net::FakeURLFetcherFactory fetcher_factory_; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 })); | 300 })); |
302 | 301 |
303 session_.reset(); | 302 session_.reset(); |
304 base::RunLoop().RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
305 } | 304 } |
306 | 305 |
307 // TODO(vitalybuka): replace PrivetHTTPClient with regular URL fetcher and | 306 // TODO(vitalybuka): replace PrivetHTTPClient with regular URL fetcher and |
308 // implement SendMessage test. | 307 // implement SendMessage test. |
309 | 308 |
310 } // namespace extensions | 309 } // namespace extensions |
OLD | NEW |