Commit 13648c69 authored by joedow's avatar joedow Committed by Commit bot

Updated the formatting for the app remoting test driver files using...

Updated the formatting for the app remoting test driver files using clag-format for consistency.  No logic changes.

BUG=

Review URL: https://codereview.chromium.org/1037723003

Cr-Commit-Position: refs/heads/master@{#322311}
parent 412f817a
...@@ -33,7 +33,8 @@ AccessTokenFetcher::AccessTokenFetcher() { ...@@ -33,7 +33,8 @@ AccessTokenFetcher::AccessTokenFetcher() {
kOauthRedirectUrl}; kOauthRedirectUrl};
} }
AccessTokenFetcher::~AccessTokenFetcher() {} AccessTokenFetcher::~AccessTokenFetcher() {
}
void AccessTokenFetcher::GetAccessTokenFromAuthCode( void AccessTokenFetcher::GetAccessTokenFromAuthCode(
const std::string& auth_code, const std::string& auth_code,
...@@ -70,9 +71,7 @@ void AccessTokenFetcher::GetAccessTokenFromRefreshToken( ...@@ -70,9 +71,7 @@ void AccessTokenFetcher::GetAccessTokenFromRefreshToken(
// Create a new GaiaOAuthClient for each request to GAIA. // Create a new GaiaOAuthClient for each request to GAIA.
CreateNewGaiaOAuthClientInstance(); CreateNewGaiaOAuthClientInstance();
auth_client_->RefreshToken( auth_client_->RefreshToken(oauth_client_info_, refresh_token_,
oauth_client_info_,
refresh_token_,
std::vector<std::string>(), // scopes std::vector<std::string>(), // scopes
kMaxGetTokensRetries, kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate this); // GaiaOAuthClient::Delegate* delegate
...@@ -180,9 +179,7 @@ void AccessTokenFetcher::ValidateAccessToken() { ...@@ -180,9 +179,7 @@ void AccessTokenFetcher::ValidateAccessToken() {
// Create a new GaiaOAuthClient for each request to GAIA. // Create a new GaiaOAuthClient for each request to GAIA.
CreateNewGaiaOAuthClientInstance(); CreateNewGaiaOAuthClientInstance();
auth_client_->GetTokenInfo( auth_client_->GetTokenInfo(access_token_, kMaxGetTokensRetries,
access_token_,
kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate this); // GaiaOAuthClient::Delegate* delegate
} }
......
...@@ -17,9 +17,9 @@ namespace test { ...@@ -17,9 +17,9 @@ namespace test {
// Supplied by the client for each request to GAIA and returns valid tokens on // Supplied by the client for each request to GAIA and returns valid tokens on
// success or empty tokens on failure. // success or empty tokens on failure.
typedef base::Callback<void( typedef base::Callback<void(const std::string& access_token,
const std::string& access_token, const std::string& refresh_token)>
const std::string& refresh_token)> AccessTokenCallback; AccessTokenCallback;
// Retrieves an access token from either an authorization code or a refresh // Retrieves an access token from either an authorization code or a refresh
// token. Destroying the AccessTokenFetcher while a request is outstanding will // token. Destroying the AccessTokenFetcher while a request is outstanding will
......
...@@ -48,8 +48,9 @@ std::string GetAuthorizationCodeUri() { ...@@ -48,8 +48,9 @@ std::string GetAuthorizationCodeUri() {
"&access_type=offline" "&access_type=offline"
"&approval_prompt=force", "&approval_prompt=force",
net::EscapeUrlEncodedData(kAppRemotingAuthScopeValues, use_plus).c_str(), net::EscapeUrlEncodedData(kAppRemotingAuthScopeValues, use_plus).c_str(),
net::EscapeUrlEncodedData(google_apis::GetOAuth2ClientID( net::EscapeUrlEncodedData(
google_apis::CLIENT_REMOTING), use_plus).c_str()); google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING),
use_plus).c_str());
} }
void PrintUsage() { void PrintUsage() {
...@@ -69,10 +70,12 @@ void PrintUsage() { ...@@ -69,10 +70,12 @@ void PrintUsage() {
switches::kHelpSwitchName); switches::kHelpSwitchName);
printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n", printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n",
switches::kServiceEnvironmentSwitchName); switches::kServiceEnvironmentSwitchName);
printf(" %s: Retrieves and displays the connection status for all known " printf(
" %s: Retrieves and displays the connection status for all known "
"hosts, no tests will be run\n", "hosts, no tests will be run\n",
switches::kShowHostAvailabilitySwitchName); switches::kShowHostAvailabilitySwitchName);
printf(" %s: Specifies the optional logging level of the tool (0-3)." printf(
" %s: Specifies the optional logging level of the tool (0-3)."
" [default: off]\n", " [default: off]\n",
switches::kLoggingLevelSwitchName); switches::kLoggingLevelSwitchName);
} }
...@@ -93,7 +96,8 @@ void PrintAuthCodeInfo() { ...@@ -93,7 +96,8 @@ void PrintAuthCodeInfo() {
printf("\n has been revoked or expired.\n"); printf("\n has been revoked or expired.\n");
printf(" Passing in the same auth code twice will result in an error\n"); printf(" Passing in the same auth code twice will result in an error\n");
printf("\nFollow these steps to produce an auth code:\n" printf(
"\nFollow these steps to produce an auth code:\n"
" - Open the Authorization URL link shown below in your browser\n" " - Open the Authorization URL link shown below in your browser\n"
" - Approve the requested permissions for the tool\n" " - Approve the requested permissions for the tool\n"
" - Copy the 'code' value in the redirected URL\n" " - Copy the 'code' value in the redirected URL\n"
...@@ -103,7 +107,8 @@ void PrintAuthCodeInfo() { ...@@ -103,7 +107,8 @@ void PrintAuthCodeInfo() {
printf("%s\n", GetAuthorizationCodeUri().c_str()); printf("%s\n", GetAuthorizationCodeUri().c_str());
printf("\nRedirected URL Example:\n"); printf("\nRedirected URL Example:\n");
printf("https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/" printf(
"https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/"
"chrome-remote-desktop/dev?code=4/AKtf...\n"); "chrome-remote-desktop/dev?code=4/AKtf...\n");
printf("\nTool usage example with the newly created auth code:\n"); printf("\nTool usage example with the newly created auth code:\n");
......
...@@ -142,8 +142,8 @@ void AppRemotingTestDriverEnvironment::ShowHostAvailability() { ...@@ -142,8 +142,8 @@ void AppRemotingTestDriverEnvironment::ShowHostAvailability() {
while (it != application_names_.end()) { while (it != application_names_.end()) {
std::string application_name = *it; std::string application_name = *it;
const RemoteApplicationDetails& application_details = GetDetailsFromAppName( const RemoteApplicationDetails& application_details =
application_name); GetDetailsFromAppName(application_name);
RemoteHostInfo remote_host_info; RemoteHostInfo remote_host_info;
GetRemoteHostInfoForApplicationId(application_details.application_id, GetRemoteHostInfoForApplicationId(application_details.application_id,
......
...@@ -26,15 +26,13 @@ using testing::_; ...@@ -26,15 +26,13 @@ using testing::_;
// file system dependencies when testing the TestDriverEnvironment. // file system dependencies when testing the TestDriverEnvironment.
class FakeRefreshTokenStore : public RefreshTokenStore { class FakeRefreshTokenStore : public RefreshTokenStore {
public: public:
FakeRefreshTokenStore() : FakeRefreshTokenStore()
refresh_token_value(kRefreshTokenValue), : refresh_token_value(kRefreshTokenValue),
refresh_token_write_succeeded(true), refresh_token_write_succeeded(true),
refresh_token_write_attempted(false) {} refresh_token_write_attempted(false) {}
~FakeRefreshTokenStore() override {} ~FakeRefreshTokenStore() override {}
std::string FetchRefreshToken() override { std::string FetchRefreshToken() override { return refresh_token_value; };
return refresh_token_value;
};
bool StoreRefreshToken(const std::string& refresh_token) override { bool StoreRefreshToken(const std::string& refresh_token) override {
// Record the information passed to us to write. // Record the information passed to us to write.
...@@ -70,8 +68,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) { ...@@ -70,8 +68,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -83,10 +80,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) { ...@@ -83,10 +80,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) {
EXPECT_TRUE(init_result); EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted); EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
EXPECT_EQ(fake_token_store.refresh_token_value_written.compare( EXPECT_EQ(fake_token_store.refresh_token_value_written.compare(
kFakeAccessTokenFetcherRefreshTokenValue), 0); kFakeAccessTokenFetcherRefreshTokenValue),
0);
EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0); EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0);
EXPECT_EQ(environment_object.access_token().compare( EXPECT_EQ(environment_object.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0); kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors. // Attempt to init again, we should not see any additional calls or errors.
init_result = environment_object.Initialize(kAuthCodeValue); init_result = environment_object.Initialize(kAuthCodeValue);
...@@ -112,8 +111,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCodeFailed) { ...@@ -112,8 +111,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCodeFailed) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -140,8 +138,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) { ...@@ -140,8 +138,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -160,7 +157,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) { ...@@ -160,7 +157,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) {
// Verify the object was initialized correctly. // Verify the object was initialized correctly.
EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0); EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0);
EXPECT_EQ(environment_object.access_token().compare( EXPECT_EQ(environment_object.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0); kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors. // Attempt to init again, we should not see any additional calls or errors.
init_result = environment_object.Initialize(std::string()); init_result = environment_object.Initialize(std::string());
...@@ -187,8 +185,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, ...@@ -187,8 +185,7 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -218,8 +215,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, ...@@ -218,8 +215,7 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -252,8 +248,7 @@ TEST(AppRemotingTestDriverEnvironmentTest, ...@@ -252,8 +248,7 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0); .Times(0);
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -284,12 +279,11 @@ TEST(AppRemotingTestDriverEnvironmentTest, ...@@ -284,12 +279,11 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _)) EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(1); .Times(1);
EXPECT_CALL(mock_access_token_fetcher, EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
GetAccessTokenFromRefreshToken(_, _)).Times(1); .Times(1);
} }
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -301,10 +295,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, ...@@ -301,10 +295,12 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_TRUE(init_result); EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted); EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
EXPECT_EQ(fake_token_store.refresh_token_value_written.compare( EXPECT_EQ(fake_token_store.refresh_token_value_written.compare(
kFakeAccessTokenFetcherRefreshTokenValue), 0); kFakeAccessTokenFetcherRefreshTokenValue),
0);
EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0); EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0);
EXPECT_EQ(environment_object.access_token().compare( EXPECT_EQ(environment_object.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0); kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors. // Attempt to init again, we should not see any additional calls or errors.
bool refresh_result = environment_object.RefreshAccessToken(); bool refresh_result = environment_object.RefreshAccessToken();
...@@ -331,12 +327,11 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) { ...@@ -331,12 +327,11 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) {
.Times(1); .Times(1);
// Mock is set up for this call to fail. // Mock is set up for this call to fail.
EXPECT_CALL(mock_access_token_fetcher, EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
GetAccessTokenFromRefreshToken(_, _)).Times(1); .Times(1);
} }
AppRemotingTestDriverEnvironment environment_object( AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kUserNameValue,
kDeveloperEnvironment); kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher); environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
...@@ -348,10 +343,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) { ...@@ -348,10 +343,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) {
EXPECT_TRUE(init_result); EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted); EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
EXPECT_EQ(fake_token_store.refresh_token_value_written.compare( EXPECT_EQ(fake_token_store.refresh_token_value_written.compare(
kFakeAccessTokenFetcherRefreshTokenValue), 0); kFakeAccessTokenFetcherRefreshTokenValue),
0);
EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0); EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0);
EXPECT_EQ(environment_object.access_token().compare( EXPECT_EQ(environment_object.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0); kFakeAccessTokenFetcherAccessTokenValue),
0);
fake_access_token_fetcher->set_fail_access_token_from_refresh_token(true); fake_access_token_fetcher->set_fail_access_token_from_refresh_token(true);
......
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
namespace remoting { namespace remoting {
namespace test { namespace test {
FakeAccessTokenFetcher::FakeAccessTokenFetcher() : FakeAccessTokenFetcher::FakeAccessTokenFetcher()
fail_access_token_from_auth_code_(false), : fail_access_token_from_auth_code_(false),
fail_access_token_from_refresh_token_(false) {} fail_access_token_from_refresh_token_(false) {
}
FakeAccessTokenFetcher::~FakeAccessTokenFetcher() {}
FakeAccessTokenFetcher::~FakeAccessTokenFetcher() {
}
void FakeAccessTokenFetcher::GetAccessTokenFromAuthCode( void FakeAccessTokenFetcher::GetAccessTokenFromAuthCode(
const std::string& auth_code, const std::string& auth_code,
......
...@@ -24,8 +24,7 @@ class FakeAccessTokenFetcher : public AccessTokenFetcher { ...@@ -24,8 +24,7 @@ class FakeAccessTokenFetcher : public AccessTokenFetcher {
~FakeAccessTokenFetcher() override; ~FakeAccessTokenFetcher() override;
// AccessTokenFetcher interface. // AccessTokenFetcher interface.
void GetAccessTokenFromAuthCode( void GetAccessTokenFromAuthCode(const std::string& auth_code,
const std::string& auth_code,
const AccessTokenCallback& callback) override; const AccessTokenCallback& callback) override;
void GetAccessTokenFromRefreshToken( void GetAccessTokenFromRefreshToken(
const std::string& refresh_token, const std::string& refresh_token,
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
namespace remoting { namespace remoting {
namespace test { namespace test {
FakeRemoteHostInfoFetcher::FakeRemoteHostInfoFetcher() : FakeRemoteHostInfoFetcher::FakeRemoteHostInfoFetcher()
fail_retrieve_remote_host_info_(false) {} : fail_retrieve_remote_host_info_(false) {
}
FakeRemoteHostInfoFetcher::~FakeRemoteHostInfoFetcher() {} FakeRemoteHostInfoFetcher::~FakeRemoteHostInfoFetcher() {
}
bool FakeRemoteHostInfoFetcher::RetrieveRemoteHostInfo( bool FakeRemoteHostInfoFetcher::RetrieveRemoteHostInfo(
const std::string& application_id, const std::string& application_id,
......
...@@ -21,8 +21,7 @@ class FakeRemoteHostInfoFetcher : public RemoteHostInfoFetcher { ...@@ -21,8 +21,7 @@ class FakeRemoteHostInfoFetcher : public RemoteHostInfoFetcher {
~FakeRemoteHostInfoFetcher() override; ~FakeRemoteHostInfoFetcher() override;
// RemoteHostInfoFetcher interface. // RemoteHostInfoFetcher interface.
bool RetrieveRemoteHostInfo( bool RetrieveRemoteHostInfo(const std::string& application_id,
const std::string& application_id,
const std::string& access_token, const std::string& access_token,
ServiceEnvironment service_environment, ServiceEnvironment service_environment,
const RemoteHostInfoCallback& callback) override; const RemoteHostInfoCallback& callback) override;
......
...@@ -20,10 +20,11 @@ void MockAccessTokenFetcher::SetAccessTokenFetcher( ...@@ -20,10 +20,11 @@ void MockAccessTokenFetcher::SetAccessTokenFetcher(
scoped_ptr<AccessTokenFetcher> fetcher) { scoped_ptr<AccessTokenFetcher> fetcher) {
internal_access_token_fetcher_ = fetcher.Pass(); internal_access_token_fetcher_ = fetcher.Pass();
ON_CALL(*this, GetAccessTokenFromAuthCode(_, _)).WillByDefault( ON_CALL(*this, GetAccessTokenFromAuthCode(_, _))
Invoke(internal_access_token_fetcher_.get(), .WillByDefault(Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromAuthCode)); &AccessTokenFetcher::GetAccessTokenFromAuthCode));
ON_CALL(*this, GetAccessTokenFromRefreshToken(_, _)).WillByDefault( ON_CALL(*this, GetAccessTokenFromRefreshToken(_, _))
.WillByDefault(
Invoke(internal_access_token_fetcher_.get(), Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromRefreshToken)); &AccessTokenFetcher::GetAccessTokenFromRefreshToken));
} }
......
...@@ -24,8 +24,8 @@ base::FilePath GetRefreshTokenDirPath(const std::string& user_name) { ...@@ -24,8 +24,8 @@ base::FilePath GetRefreshTokenDirPath(const std::string& user_name) {
} }
refresh_token_dir_path = refresh_token_dir_path.Append(kRemotingFolder); refresh_token_dir_path = refresh_token_dir_path.Append(kRemotingFolder);
refresh_token_dir_path = refresh_token_dir_path.Append( refresh_token_dir_path =
kRefreshTokenStoreFolder); refresh_token_dir_path.Append(kRefreshTokenStoreFolder);
// We call AppendASCII here our user_name is a std::string but wide strings // We call AppendASCII here our user_name is a std::string but wide strings
// are used on WIN platforms. ApendASCII will convert our std::string into // are used on WIN platforms. ApendASCII will convert our std::string into
...@@ -58,10 +58,12 @@ class RefreshTokenStoreOnDisk : public RefreshTokenStore { ...@@ -58,10 +58,12 @@ class RefreshTokenStoreOnDisk : public RefreshTokenStore {
DISALLOW_COPY_AND_ASSIGN(RefreshTokenStoreOnDisk); DISALLOW_COPY_AND_ASSIGN(RefreshTokenStoreOnDisk);
}; };
RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name) : RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name)
user_name_(user_name) {} : user_name_(user_name) {
}
RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {} RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {
}
std::string RefreshTokenStoreOnDisk::FetchRefreshToken() { std::string RefreshTokenStoreOnDisk::FetchRefreshToken() {
base::FilePath token_dir_path(GetRefreshTokenDirPath(user_name_)); base::FilePath token_dir_path(GetRefreshTokenDirPath(user_name_));
...@@ -131,8 +133,8 @@ bool RefreshTokenStoreOnDisk::StoreRefreshToken( ...@@ -131,8 +133,8 @@ bool RefreshTokenStoreOnDisk::StoreRefreshToken(
scoped_ptr<RefreshTokenStore> RefreshTokenStore::OnDisk( scoped_ptr<RefreshTokenStore> RefreshTokenStore::OnDisk(
const std::string& user_name) { const std::string& user_name) {
return make_scoped_ptr<RefreshTokenStore>(new RefreshTokenStoreOnDisk( return make_scoped_ptr<RefreshTokenStore>(
user_name)); new RefreshTokenStoreOnDisk(user_name));
} }
} // namespace test } // namespace test
......
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
namespace remoting { namespace remoting {
namespace test { namespace test {
RemoteHostInfo::RemoteHostInfo() : RemoteHostInfo::RemoteHostInfo()
remote_host_status(kRemoteHostStatusUnknown) {} : remote_host_status(kRemoteHostStatusUnknown) {
}
RemoteHostInfo::~RemoteHostInfo() {} RemoteHostInfo::~RemoteHostInfo() {
}
bool RemoteHostInfo::IsReadyForConnection() const { bool RemoteHostInfo::IsReadyForConnection() const {
return (remote_host_status == kRemoteHostStatusReady); return (remote_host_status == kRemoteHostStatusReady);
......
...@@ -43,8 +43,7 @@ namespace test { ...@@ -43,8 +43,7 @@ namespace test {
// necessary, for use by the RemoteHostInfoFetcher. // necessary, for use by the RemoteHostInfoFetcher.
class RemoteHostInfoFetcherTest : public ::testing::Test { class RemoteHostInfoFetcherTest : public ::testing::Test {
public: public:
RemoteHostInfoFetcherTest() : RemoteHostInfoFetcherTest() : url_fetcher_factory_(nullptr) {}
url_fetcher_factory_(nullptr) {}
~RemoteHostInfoFetcherTest() override {} ~RemoteHostInfoFetcherTest() override {}
// Used as a RemoteHostInfoCallback for testing. // Used as a RemoteHostInfoCallback for testing.
...@@ -57,8 +56,7 @@ class RemoteHostInfoFetcherTest : public ::testing::Test { ...@@ -57,8 +56,7 @@ class RemoteHostInfoFetcherTest : public ::testing::Test {
void SetUp() override; void SetUp() override;
// Sets the HTTP status and data returned for a specified URL. // Sets the HTTP status and data returned for a specified URL.
void SetFakeResponse( void SetFakeResponse(const GURL& url,
const GURL& url,
const std::string& data, const std::string& data,
net::HttpStatusCode code, net::HttpStatusCode code,
net::URLRequestStatus::Status status); net::URLRequestStatus::Status status);
...@@ -92,13 +90,11 @@ void RemoteHostInfoFetcherTest::SetUp() { ...@@ -92,13 +90,11 @@ void RemoteHostInfoFetcherTest::SetUp() {
message_loop_.reset(new base::MessageLoopForIO); message_loop_.reset(new base::MessageLoopForIO);
} }
dev_service_environment_url_ = base::StringPrintf( dev_service_environment_url_ =
kDevServiceEnvironmentUrlFormat, base::StringPrintf(kDevServiceEnvironmentUrlFormat, kTestApplicationId);
kTestApplicationId);
test_service_environment_url_ = base::StringPrintf( test_service_environment_url_ =
kTestServiceEnvironmentUrlFormat, base::StringPrintf(kTestServiceEnvironmentUrlFormat, kTestApplicationId);
kTestApplicationId);
} }
void RemoteHostInfoFetcherTest::SetFakeResponse( void RemoteHostInfoFetcherTest::SetFakeResponse(
...@@ -110,29 +106,22 @@ void RemoteHostInfoFetcherTest::SetFakeResponse( ...@@ -110,29 +106,22 @@ void RemoteHostInfoFetcherTest::SetFakeResponse(
} }
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) { TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) {
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoReadyResponse, net::HTTP_OK,
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
SetFakeResponse( SetFakeResponse(GURL(test_service_environment_url_),
GURL(test_service_environment_url_), kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED); net::URLRequestStatus::FAILED);
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
kAccessTokenValue,
kDeveloperEnvironment,
remote_host_info_callback); remote_host_info_callback);
run_loop.Run(); run_loop.Run();
...@@ -147,29 +136,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) { ...@@ -147,29 +136,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) {
} }
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromTest) { TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromTest) {
SetFakeResponse( SetFakeResponse(GURL(test_service_environment_url_),
GURL(test_service_environment_url_), kRemoteHostInfoReadyResponse, net::HTTP_OK,
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED); net::URLRequestStatus::FAILED);
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kTestingEnvironment,
kAccessTokenValue,
kTestingEnvironment,
remote_host_info_callback); remote_host_info_callback);
run_loop.Run(); run_loop.Run();
...@@ -187,37 +169,29 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoInvalidEnvironment) { ...@@ -187,37 +169,29 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoInvalidEnvironment) {
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kUnknownEnvironment,
kAccessTokenValue,
kUnknownEnvironment,
remote_host_info_callback); remote_host_info_callback);
EXPECT_FALSE(request_started); EXPECT_FALSE(request_started);
} }
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) { TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) {
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoReadyResponse, net::HTTP_NOT_FOUND,
kRemoteHostInfoReadyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED); net::URLRequestStatus::FAILED);
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
kAccessTokenValue,
kDeveloperEnvironment,
remote_host_info_callback); remote_host_info_callback);
run_loop.Run(); run_loop.Run();
...@@ -235,23 +209,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) { ...@@ -235,23 +209,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) {
} }
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) { TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) {
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoPendingResponse, net::HTTP_OK,
kRemoteHostInfoPendingResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
kAccessTokenValue,
kDeveloperEnvironment,
remote_host_info_callback); remote_host_info_callback);
run_loop.Run(); run_loop.Run();
...@@ -269,23 +238,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) { ...@@ -269,23 +238,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) {
} }
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) { TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) {
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoEmptyResponse, net::HTTP_OK,
kRemoteHostInfoEmptyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
base::RunLoop run_loop; base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback = RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), run_loop.QuitClosure());
run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
kAccessTokenValue,
kDeveloperEnvironment,
remote_host_info_callback); remote_host_info_callback);
run_loop.Run(); run_loop.Run();
...@@ -304,29 +268,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) { ...@@ -304,29 +268,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) {
TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) { TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) {
// First, we will fetch info from the development service environment. // First, we will fetch info from the development service environment.
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoReadyResponse, net::HTTP_OK,
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
SetFakeResponse( SetFakeResponse(GURL(test_service_environment_url_),
GURL(test_service_environment_url_), kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED); net::URLRequestStatus::FAILED);
base::RunLoop dev_run_loop; base::RunLoop dev_run_loop;
RemoteHostInfoCallback dev_remote_host_info_callback = RemoteHostInfoCallback dev_remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), dev_run_loop.QuitClosure());
dev_run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher; RemoteHostInfoFetcher remote_host_info_fetcher;
bool dev_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool dev_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
kAccessTokenValue,
kDeveloperEnvironment,
dev_remote_host_info_callback); dev_remote_host_info_callback);
dev_run_loop.Run(); dev_run_loop.Run();
...@@ -340,32 +297,25 @@ TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) { ...@@ -340,32 +297,25 @@ TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) {
EXPECT_TRUE(!remote_host_info_.shared_secret.empty()); EXPECT_TRUE(!remote_host_info_.shared_secret.empty());
// Next, we will fetch info from the test service environment. // Next, we will fetch info from the test service environment.
SetFakeResponse( SetFakeResponse(GURL(test_service_environment_url_),
GURL(test_service_environment_url_), kRemoteHostInfoReadyResponse, net::HTTP_OK,
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS); net::URLRequestStatus::SUCCESS);
SetFakeResponse( SetFakeResponse(GURL(dev_service_environment_url_),
GURL(dev_service_environment_url_), kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED); net::URLRequestStatus::FAILED);
base::RunLoop test_run_loop; base::RunLoop test_run_loop;
RemoteHostInfoCallback test_remote_host_info_callback = RemoteHostInfoCallback test_remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved, base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this), base::Unretained(this), test_run_loop.QuitClosure());
test_run_loop.QuitClosure());
// Reset the state of our internal |remote_host_info_| object. // Reset the state of our internal |remote_host_info_| object.
remote_host_info_ = RemoteHostInfo(); remote_host_info_ = RemoteHostInfo();
EXPECT_FALSE(remote_host_info_.IsReadyForConnection()); EXPECT_FALSE(remote_host_info_.IsReadyForConnection());
bool test_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo( bool test_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId, kTestApplicationId, kAccessTokenValue, kTestingEnvironment,
kAccessTokenValue,
kTestingEnvironment,
test_remote_host_info_callback); test_remote_host_info_callback);
test_run_loop.Run(); test_run_loop.Run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment