| 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..59a4662aadb7ef1005e2eb5200ffec8639566d29 100644
|
| --- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
|
| +++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/login/user.h"
|
| #include "chrome/browser/chromeos/login/user_manager.h"
|
| +#include "chrome/browser/extensions/api/networking_private/networking_private_process_client.h"
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| #include "chrome/browser/policy/browser_policy_connector.h"
|
| #include "chrome/browser/policy/external_data_fetcher.h"
|
| @@ -14,6 +15,7 @@
|
| #include "chrome/browser/policy/policy_map.h"
|
| #include "chrome/browser/policy/policy_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/extensions/api/networking_private.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| @@ -29,17 +31,47 @@
|
| #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;
|
| +using chromeos::DBusThreadManager;
|
| +using chromeos::ShillDeviceClient;
|
| +using chromeos::ShillManagerClient;
|
| +using chromeos::ShillProfileClient;
|
| +using chromeos::ShillServiceClient;
|
| #endif // OS_CHROMEOS
|
| +
|
| using testing::AnyNumber;
|
| using testing::Return;
|
| using testing::_;
|
| +using extensions::api::networking_private::VerificationProperties;
|
|
|
| -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
|
| + : public extensions::NetworkingPrivateProcessClient::CryptoVerify {
|
| + virtual bool VerifyDestination(
|
| + const VerificationProperties& properties) OVERRIDE {
|
| + return true;
|
| + }
|
| +
|
| + virtual bool VerifyAndEncryptData(const VerificationProperties& properties,
|
| + const std::string& plain_data,
|
| + std::string* encoded_data) OVERRIDE {
|
| + *encoded_data = "encrypted_data";
|
| + return true;
|
| + }
|
| +};
|
|
|
| class ExtensionNetworkingPrivateApiTest :
|
| public ExtensionApiTest,
|
| @@ -77,10 +109,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 +164,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",
|
| @@ -220,7 +253,18 @@ class ExtensionNetworkingPrivateApiTest :
|
| virtual void SetUpOnMainThread() OVERRIDE {
|
| ExtensionApiTest::SetUpOnMainThread();
|
| content::RunAllPendingInMessageLoop();
|
| + base::DictionaryValue mock_parameters;
|
| + process_client_ =
|
| + extensions::NetworkingPrivateProcessClient::GetForProfile(profile());
|
| + // Use Mock WiFiService to test plumbing.
|
| + process_client_->SetUpForTest(mock_parameters, new CryptoVerifyMock());
|
| + }
|
| +
|
| + virtual void TearDownOnMainThread() OVERRIDE {
|
| + process_client_->TearDownForTest();
|
| }
|
| +
|
| + scoped_refptr<extensions::NetworkingPrivateProcessClient> process_client_;
|
| #endif // OS_CHROMEOS
|
|
|
| protected:
|
| @@ -256,10 +300,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 +328,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 +426,5 @@ INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation,
|
| ExtensionNetworkingPrivateApiTest,
|
| testing::Bool());
|
|
|
| -} // namespace chromeos
|
| +} // namespace
|
| +
|
|
|