| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 int send_packet_counter_ = 0; | 111 int send_packet_counter_ = 0; |
| 112 std::vector<char> ip_packet_; | 112 std::vector<char> ip_packet_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class VpnProviderApiTest : public ExtensionApiTest, | 115 class VpnProviderApiTest : public ExtensionApiTest, |
| 116 public NetworkConfigurationObserver { | 116 public NetworkConfigurationObserver { |
| 117 public: | 117 public: |
| 118 VpnProviderApiTest() {} | 118 VpnProviderApiTest() {} |
| 119 ~VpnProviderApiTest() override {} | 119 ~VpnProviderApiTest() override {} |
| 120 | 120 |
| 121 void SetUpOnMainThread() override { |
| 122 ExtensionApiTest::SetUpOnMainThread(); |
| 123 NetworkHandler::Get()->network_configuration_handler()->AddObserver(this); |
| 124 } |
| 125 |
| 126 void TearDownOnMainThread() override { |
| 127 ExtensionApiTest::TearDownOnMainThread(); |
| 128 NetworkHandler::Get()->network_configuration_handler()->RemoveObserver( |
| 129 this); |
| 130 } |
| 131 |
| 121 void SetUpInProcessBrowserTestFixture() override { | 132 void SetUpInProcessBrowserTestFixture() override { |
| 122 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 133 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 123 test_client_ = new TestShillThirdPartyVpnDriverClient(); | 134 test_client_ = new TestShillThirdPartyVpnDriverClient(); |
| 124 DBusThreadManager::GetSetterForTesting()->SetShillThirdPartyVpnDriverClient( | 135 DBusThreadManager::GetSetterForTesting()->SetShillThirdPartyVpnDriverClient( |
| 125 make_scoped_ptr(test_client_)); | 136 make_scoped_ptr(test_client_)); |
| 126 } | 137 } |
| 127 | 138 |
| 128 void AddNetworkProfileForUser() { | 139 void AddNetworkProfileForUser() { |
| 129 static_cast<FakeShillProfileClient*>( | 140 static_cast<FakeShillProfileClient*>( |
| 130 DBusThreadManager::Get()->GetShillProfileClient()) | 141 DBusThreadManager::Get()->GetShillProfileClient()) |
| 131 ->AddProfile( | 142 ->AddProfile( |
| 132 kNetworkProfilePath, | 143 kNetworkProfilePath, |
| 133 chromeos::ProfileHelper::GetUserIdHashFromProfile(profile())); | 144 chromeos::ProfileHelper::GetUserIdHashFromProfile(profile())); |
| 134 content::RunAllPendingInMessageLoop(); | 145 content::RunAllPendingInMessageLoop(); |
| 135 } | 146 } |
| 136 | 147 |
| 137 void LoadVpnExtension() { | 148 void LoadVpnExtension() { |
| 138 NetworkHandler::Get()->network_configuration_handler()->AddObserver(this); | |
| 139 extension_ = LoadExtension(test_data_dir_.AppendASCII("vpn_provider")); | 149 extension_ = LoadExtension(test_data_dir_.AppendASCII("vpn_provider")); |
| 140 extension_id_ = extension_->id(); | 150 extension_id_ = extension_->id(); |
| 141 service_ = VpnServiceFactory::GetForBrowserContext(profile()); | 151 service_ = VpnServiceFactory::GetForBrowserContext(profile()); |
| 142 content::RunAllPendingInMessageLoop(); | 152 content::RunAllPendingInMessageLoop(); |
| 143 } | 153 } |
| 144 | 154 |
| 145 bool RunExtensionTest(const std::string& test_name) { | 155 bool RunExtensionTest(const std::string& test_name) { |
| 146 GURL url = extension_->GetResourceURL("basic.html?#" + test_name); | 156 GURL url = extension_->GetResourceURL("basic.html?#" + test_name); |
| 147 return RunExtensionSubtest("vpn_provider", url.spec()); | 157 return RunExtensionSubtest("vpn_provider", url.spec()); |
| 148 } | 158 } |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 extension_service->BlacklistExtensionForTest(extension_id_); | 477 extension_service->BlacklistExtensionForTest(extension_id_); |
| 468 content::RunAllPendingInMessageLoop(); | 478 content::RunAllPendingInMessageLoop(); |
| 469 EXPECT_FALSE(DoesConfigExist(kTestConfig)); | 479 EXPECT_FALSE(DoesConfigExist(kTestConfig)); |
| 470 EXPECT_FALSE(DBusThreadManager::Get() | 480 EXPECT_FALSE(DBusThreadManager::Get() |
| 471 ->GetShillProfileClient() | 481 ->GetShillProfileClient() |
| 472 ->GetTestInterface() | 482 ->GetTestInterface() |
| 473 ->GetService(service_path, &profile_path, &properties)); | 483 ->GetService(service_path, &profile_path, &properties)); |
| 474 } | 484 } |
| 475 | 485 |
| 476 } // namespace chromeos | 486 } // namespace chromeos |
| OLD | NEW |