| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/api/networking_private/networking_private_cr
edentials_getter.h" | 10 #include "chrome/browser/extensions/api/networking_private/networking_private_cr
edentials_getter.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // dependency. | 31 // dependency. |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Stub Verify* methods implementation to satisfy expectations of | 35 // Stub Verify* methods implementation to satisfy expectations of |
| 36 // networking_private_apitest. | 36 // networking_private_apitest. |
| 37 class CryptoVerifyStub | 37 class CryptoVerifyStub |
| 38 : public extensions::NetworkingPrivateServiceClient::CryptoVerify { | 38 : public extensions::NetworkingPrivateServiceClient::CryptoVerify { |
| 39 virtual void VerifyDestination(const Credentials& verification_properties, | 39 virtual void VerifyDestination(const Credentials& verification_properties, |
| 40 bool* verified, | 40 bool* verified, |
| 41 std::string* error) OVERRIDE { | 41 std::string* error) override { |
| 42 *verified = true; | 42 *verified = true; |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void VerifyAndEncryptCredentials( | 45 virtual void VerifyAndEncryptCredentials( |
| 46 const std::string& network_guid, | 46 const std::string& network_guid, |
| 47 const Credentials& credentials, | 47 const Credentials& credentials, |
| 48 const VerifyAndEncryptCredentialsCallback& callback) OVERRIDE { | 48 const VerifyAndEncryptCredentialsCallback& callback) override { |
| 49 callback.Run("encrypted_credentials", ""); | 49 callback.Run("encrypted_credentials", ""); |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void VerifyAndEncryptData(const Credentials& verification_properties, | 52 virtual void VerifyAndEncryptData(const Credentials& verification_properties, |
| 53 const std::string& data, | 53 const std::string& data, |
| 54 std::string* base64_encoded_ciphertext, | 54 std::string* base64_encoded_ciphertext, |
| 55 std::string* error) OVERRIDE { | 55 std::string* error) override { |
| 56 *base64_encoded_ciphertext = "encrypted_data"; | 56 *base64_encoded_ciphertext = "encrypted_data"; |
| 57 } | 57 } |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest { | 60 class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest { |
| 61 public: | 61 public: |
| 62 NetworkingPrivateServiceClientApiTest() {} | 62 NetworkingPrivateServiceClientApiTest() {} |
| 63 | 63 |
| 64 bool RunNetworkingSubtest(const std::string& subtest) { | 64 bool RunNetworkingSubtest(const std::string& subtest) { |
| 65 return RunExtensionSubtest("networking", | 65 return RunExtensionSubtest("networking", |
| 66 "main.html?" + subtest, | 66 "main.html?" + subtest, |
| 67 kFlagEnableFileAccess | kFlagLoadAsComponent); | 67 kFlagEnableFileAccess | kFlagLoadAsComponent); |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 70 virtual void SetUpInProcessBrowserTestFixture() override { |
| 71 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 71 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 74 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 75 ExtensionApiTest::SetUpCommandLine(command_line); | 75 ExtensionApiTest::SetUpCommandLine(command_line); |
| 76 // Whitelist the extension ID of the test extension. | 76 // Whitelist the extension ID of the test extension. |
| 77 command_line->AppendSwitchASCII( | 77 command_line->AppendSwitchASCII( |
| 78 extensions::switches::kWhitelistedExtensionID, | 78 extensions::switches::kWhitelistedExtensionID, |
| 79 "epcifkihnkjgphfkloaaleeakhpmgdmn"); | 79 "epcifkihnkjgphfkloaaleeakhpmgdmn"); |
| 80 } | 80 } |
| 81 | 81 |
| 82 static KeyedService* CreateNetworkingPrivateServiceClient( | 82 static KeyedService* CreateNetworkingPrivateServiceClient( |
| 83 content::BrowserContext* profile) { | 83 content::BrowserContext* profile) { |
| 84 return new NetworkingPrivateServiceClient(new wifi::FakeWiFiService(), | 84 return new NetworkingPrivateServiceClient(new wifi::FakeWiFiService(), |
| 85 new CryptoVerifyStub()); | 85 new CryptoVerifyStub()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void SetUpOnMainThread() OVERRIDE { | 88 virtual void SetUpOnMainThread() override { |
| 89 ExtensionApiTest::SetUpOnMainThread(); | 89 ExtensionApiTest::SetUpOnMainThread(); |
| 90 content::RunAllPendingInMessageLoop(); | 90 content::RunAllPendingInMessageLoop(); |
| 91 NetworkingPrivateServiceClientFactory::GetInstance()->SetTestingFactory( | 91 NetworkingPrivateServiceClientFactory::GetInstance()->SetTestingFactory( |
| 92 profile(), &CreateNetworkingPrivateServiceClient); | 92 profile(), &CreateNetworkingPrivateServiceClient); |
| 93 } | 93 } |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateServiceClientApiTest); | 96 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateServiceClientApiTest); |
| 97 }; | 97 }; |
| 98 | 98 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 VerifyAndEncryptCredentials) { | 200 VerifyAndEncryptCredentials) { |
| 201 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; | 201 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; |
| 202 } | 202 } |
| 203 | 203 |
| 204 IN_PROC_BROWSER_TEST_F(NetworkingPrivateServiceClientApiTest, | 204 IN_PROC_BROWSER_TEST_F(NetworkingPrivateServiceClientApiTest, |
| 205 VerifyAndEncryptData) { | 205 VerifyAndEncryptData) { |
| 206 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; | 206 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace | 209 } // namespace |
| OLD | NEW |