Chromium Code Reviews| Index: chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
| diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
| index 7886eedeb25b216d954065c7d927635530493e46..7b6a8fa41327dcfda494ff66b443963eaae94623 100644 |
| --- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
| +++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
| @@ -29,17 +29,52 @@ |
| #include "components/onc/onc_constants.h" |
| #include "policy/policy_constants.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| + |
| +using chromeos::CryptohomeClient; |
| +using chromeos::DBUS_METHOD_CALL_SUCCESS; |
| +using chromeos::DBusMethodCallStatus; |
|
tbarzic
2013/11/15 22:56:30
group includes and using parts together.
i.e.
#if
mef
2013/11/17 20:05:18
Done.
|
| +using chromeos::DBusThreadManager; |
| +using chromeos::ShillDeviceClient; |
| +using chromeos::ShillManagerClient; |
| +using chromeos::ShillProfileClient; |
| +using chromeos::ShillServiceClient; |
| +#else |
| +#include "chrome/browser/extensions/api/networking_private/networking_private_service_client.h" |
| +#include "chrome/browser/extensions/api/networking_private/networking_private_service_client_factory.h" |
| +#include "components/wifi/wifi_service.h" |
| + |
| +using extensions::NetworkingPrivateServiceClientFactory; |
| #endif // OS_CHROMEOS |
| + |
| using testing::AnyNumber; |
| using testing::Return; |
| using testing::_; |
| -namespace chromeos { |
| +namespace { |
| #if defined(OS_CHROMEOS) |
| const char kUser1ProfilePath[] = "/profile/user1/shill"; |
| #endif // defined(OS_CHROMEOS) |
| +// Mock Verify* methods implementation to satisfy expectations of |
| +// networking_private_apitest. |
| +// TODO(mef): Fix ChromeOS implementation to use NetworkingPrivateCrypto, |
| +// and update networking_private_apitest to use and expect valid data. |
| +// That will eliminate the need for mock implementation. |
| +class CryptoVerifyMock |
|
tbarzic
2013/11/15 22:56:30
rename to CryptoVerifyStub (as it's a stub, not a
mef
2013/11/17 20:05:18
Done.
|
| + : public extensions::NetworkingPrivateServiceClient::CryptoVerify { |
| + virtual void VerifyDestination(scoped_ptr<base::ListValue> args, |
| + bool* verified, |
| + std::string* error) OVERRIDE { |
| + *verified = true; |
| + } |
| + |
| + virtual void VerifyAndEncryptData(scoped_ptr<base::ListValue> args, |
| + std::string* encoded_data, |
| + std::string* error) OVERRIDE { |
| + *encoded_data = "encrypted_data"; |
| + } |
| +}; |
| class ExtensionNetworkingPrivateApiTest : |
| public ExtensionApiTest, |
| @@ -77,10 +112,11 @@ class ExtensionNetworkingPrivateApiTest : |
| // TODO(pneubeck): Remove the following hack, once the NetworkingPrivateAPI |
| // uses the ProfileHelper to obtain the userhash crbug/238623. |
| std::string login_user = |
| - command_line->GetSwitchValueNative(switches::kLoginUser); |
| + command_line->GetSwitchValueNative(chromeos::switches::kLoginUser); |
| std::string sanitized_user = CryptohomeClient::GetStubSanitizedUsername( |
| login_user); |
| - command_line->AppendSwitchASCII(switches::kLoginProfile, sanitized_user); |
| + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, |
| + sanitized_user); |
| if (GetParam()) |
| command_line->AppendSwitch(::switches::kMultiProfiles); |
| } |
| @@ -131,8 +167,8 @@ class ExtensionNetworkingPrivateApiTest : |
| service_test->SetServiceProperty( |
| "stub_ethernet", |
| shill::kProfileProperty, |
| - base::StringValue(shill_stub_helper::kSharedProfilePath)); |
| - profile_test->AddService(shill_stub_helper::kSharedProfilePath, |
| + base::StringValue(chromeos::shill_stub_helper::kSharedProfilePath)); |
| + profile_test->AddService(chromeos::shill_stub_helper::kSharedProfilePath, |
| "stub_ethernet"); |
| service_test->AddService("stub_wifi1", "wifi1", |
| @@ -217,10 +253,22 @@ class ExtensionNetworkingPrivateApiTest : |
| "epcifkihnkjgphfkloaaleeakhpmgdmn"); |
| } |
| + static BrowserContextKeyedService* |
| + CreateNetworkingPrivateServiceClient(content::BrowserContext* profile) { |
| + return new extensions::NetworkingPrivateServiceClient( |
| + static_cast<Profile*>(profile), |
| + wifi::WiFiService::CreateServiceMock(), |
| + new CryptoVerifyMock()); |
| + } |
| + |
| virtual void SetUpOnMainThread() OVERRIDE { |
| ExtensionApiTest::SetUpOnMainThread(); |
| content::RunAllPendingInMessageLoop(); |
| + NetworkingPrivateServiceClientFactory::GetInstance()->SetTestingFactory( |
| + profile(), |
| + &CreateNetworkingPrivateServiceClient); |
| } |
| + |
| #endif // OS_CHROMEOS |
| protected: |
| @@ -256,10 +304,6 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
| << message_; |
| } |
| -IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, CreateNetwork) { |
| - EXPECT_TRUE(RunNetworkingSubtest("createNetwork")) << message_; |
| -} |
| - |
| IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetVisibleNetworks) { |
| EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworks")) << message_; |
| } |
| @@ -288,6 +332,10 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, SetProperties) { |
| } |
| #if defined(OS_CHROMEOS) |
| +IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, CreateNetwork) { |
| + EXPECT_TRUE(RunNetworkingSubtest("createNetwork")) << message_; |
| +} |
| + |
| IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetStateNonExistent) { |
| EXPECT_TRUE(RunNetworkingSubtest("getStateNonExistent")) << message_; |
| } |
| @@ -382,4 +430,5 @@ INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, |
| ExtensionNetworkingPrivateApiTest, |
| testing::Bool()); |
| -} // namespace chromeos |
| +} // namespace |
| + |