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/local_discovery/privetv3_session.h" | 5 #include "chrome/browser/local_discovery/privetv3_session.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/thread_task_runner_handle.h" |
9 #include "chrome/browser/local_discovery/privet_http.h" | 10 #include "chrome/browser/local_discovery/privet_http.h" |
10 #include "content/public/test/test_utils.h" | 11 #include "content/public/test/test_utils.h" |
11 #include "crypto/hmac.h" | 12 #include "crypto/hmac.h" |
12 #include "crypto/p224_spake.h" | 13 #include "crypto/p224_spake.h" |
13 #include "net/url_request/test_url_fetcher_factory.h" | 14 #include "net/url_request/test_url_fetcher_factory.h" |
14 #include "net/url_request/url_request_test_util.h" | 15 #include "net/url_request/url_request_test_util.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace local_discovery { | 19 namespace local_discovery { |
(...skipping 14 matching lines...) Expand all Loading... |
33 "\"endpoints\":{\"httpsPort\": 443}," | 34 "\"endpoints\":{\"httpsPort\": 443}," |
34 "\"authentication\":{" | 35 "\"authentication\":{" |
35 " \"mode\":[\"anonymous\",\"pairing\",\"cloud\"]," | 36 " \"mode\":[\"anonymous\",\"pairing\",\"cloud\"]," |
36 " \"pairing\":[\"pinCode\",\"embeddedCode\"]," | 37 " \"pairing\":[\"pinCode\",\"embeddedCode\"]," |
37 " \"crypto\":[\"p224_spake2\"]" | 38 " \"crypto\":[\"p224_spake2\"]" |
38 "}}"; | 39 "}}"; |
39 | 40 |
40 class MockPrivetHTTPClient : public PrivetHTTPClient { | 41 class MockPrivetHTTPClient : public PrivetHTTPClient { |
41 public: | 42 public: |
42 MockPrivetHTTPClient() { | 43 MockPrivetHTTPClient() { |
43 request_context_ = | 44 request_context_ = new net::TestURLRequestContextGetter( |
44 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); | 45 base::ThreadTaskRunnerHandle::Get()); |
45 } | 46 } |
46 | 47 |
47 MOCK_METHOD0(GetName, const std::string&()); | 48 MOCK_METHOD0(GetName, const std::string&()); |
48 MOCK_METHOD1( | 49 MOCK_METHOD1( |
49 CreateInfoOperationPtr, | 50 CreateInfoOperationPtr, |
50 PrivetJSONOperation*(const PrivetJSONOperation::ResultCallback&)); | 51 PrivetJSONOperation*(const PrivetJSONOperation::ResultCallback&)); |
51 | 52 |
52 void RefreshPrivetToken( | 53 void RefreshPrivetToken( |
53 const PrivetURLFetcher::TokenCallback& callback) override { | 54 const PrivetURLFetcher::TokenCallback& callback) override { |
54 FAIL(); | 55 FAIL(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 .WillOnce(testing::Invoke([this](const base::DictionaryValue& data) { | 302 .WillOnce(testing::Invoke([this](const base::DictionaryValue& data) { |
302 std::string session_id; | 303 std::string session_id; |
303 EXPECT_TRUE(data.GetString("sessionId", &session_id)); | 304 EXPECT_TRUE(data.GetString("sessionId", &session_id)); |
304 })); | 305 })); |
305 } | 306 } |
306 | 307 |
307 // TODO(vitalybuka): replace PrivetHTTPClient with regular URL fetcher and | 308 // TODO(vitalybuka): replace PrivetHTTPClient with regular URL fetcher and |
308 // implement SendMessage test. | 309 // implement SendMessage test. |
309 | 310 |
310 } // namespace local_discovery | 311 } // namespace local_discovery |
OLD | NEW |