| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_context_getter.h" | 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 10 #include "chrome/common/chrome_switches.h" | |
| 11 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "net/test/embedded_test_server/embedded_test_server.h" | 11 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 14 #include "net/url_request/url_fetcher.h" | 12 #include "net/url_request/url_fetcher.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 15 |
| 18 namespace extensions { | 16 namespace extensions { |
| 19 | 17 |
| 20 namespace { | 18 namespace { |
| 21 | 19 |
| 22 using content::BrowserThread; | 20 using content::BrowserThread; |
| 23 using net::EmbeddedTestServer; | 21 using net::EmbeddedTestServer; |
| 24 | 22 |
| 25 class PrivetV3ContextGetterTest : public testing::Test, | 23 class PrivetV3ContextGetterTest : public testing::Test, |
| 26 public net::URLFetcherDelegate { | 24 public net::URLFetcherDelegate { |
| 27 protected: | 25 protected: |
| 28 PrivetV3ContextGetterTest() | 26 PrivetV3ContextGetterTest() |
| 29 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD) {} | 27 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD) {} |
| 30 | 28 |
| 31 void SetUp() override { | 29 void SetUp() override { |
| 32 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 33 switches::kEnablePrivetV3); | |
| 34 | |
| 35 context_getter_ = new extensions::PrivetV3ContextGetter( | 30 context_getter_ = new extensions::PrivetV3ContextGetter( |
| 36 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 31 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 37 } | 32 } |
| 38 | 33 |
| 39 void OnURLFetchComplete(const net::URLFetcher* source) override { | 34 void OnURLFetchComplete(const net::URLFetcher* source) override { |
| 40 done_ = true; | 35 done_ = true; |
| 41 status_ = source->GetStatus(); | 36 status_ = source->GetStatus(); |
| 42 | 37 |
| 43 base::MessageLoop::current()->PostTask(FROM_HERE, quit_); | 38 base::MessageLoop::current()->PostTask(FROM_HERE, quit_); |
| 44 } | 39 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 119 |
| 125 CreateServer(EmbeddedTestServer::TYPE_HTTPS); | 120 CreateServer(EmbeddedTestServer::TYPE_HTTPS); |
| 126 SetFingerprint(GetServerFingerprint()); | 121 SetFingerprint(GetServerFingerprint()); |
| 127 EXPECT_EQ(net::URLRequestStatus::SUCCESS, Run()); | 122 EXPECT_EQ(net::URLRequestStatus::SUCCESS, Run()); |
| 128 } | 123 } |
| 129 } | 124 } |
| 130 | 125 |
| 131 } // namespace | 126 } // namespace |
| 132 | 127 |
| 133 } // namespace extensions | 128 } // namespace extensions |
| OLD | NEW |