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() {
kOauthRedirectUrl};
}
AccessTokenFetcher::~AccessTokenFetcher() {}
AccessTokenFetcher::~AccessTokenFetcher() {
}
void AccessTokenFetcher::GetAccessTokenFromAuthCode(
const std::string& auth_code,
......@@ -70,12 +71,10 @@ void AccessTokenFetcher::GetAccessTokenFromRefreshToken(
// Create a new GaiaOAuthClient for each request to GAIA.
CreateNewGaiaOAuthClientInstance();
auth_client_->RefreshToken(
oauth_client_info_,
refresh_token_,
std::vector<std::string>(), // scopes
kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate
auth_client_->RefreshToken(oauth_client_info_, refresh_token_,
std::vector<std::string>(), // scopes
kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate
}
void AccessTokenFetcher::CreateNewGaiaOAuthClientInstance() {
......@@ -180,10 +179,8 @@ void AccessTokenFetcher::ValidateAccessToken() {
// Create a new GaiaOAuthClient for each request to GAIA.
CreateNewGaiaOAuthClientInstance();
auth_client_->GetTokenInfo(
access_token_,
kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate
auth_client_->GetTokenInfo(access_token_, kMaxGetTokensRetries,
this); // GaiaOAuthClient::Delegate* delegate
}
} // namespace test
......
......@@ -17,9 +17,9 @@ namespace test {
// Supplied by the client for each request to GAIA and returns valid tokens on
// success or empty tokens on failure.
typedef base::Callback<void(
const std::string& access_token,
const std::string& refresh_token)> AccessTokenCallback;
typedef base::Callback<void(const std::string& access_token,
const std::string& refresh_token)>
AccessTokenCallback;
// Retrieves an access token from either an authorization code or a refresh
// token. Destroying the AccessTokenFetcher while a request is outstanding will
......
......@@ -125,7 +125,7 @@ void AppRemotingConnectedClientFixture::StartConnection() {
// main application window to become visible.
DCHECK(!timer_->IsRunning());
timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(30),
run_loop_->QuitClosure());
run_loop_->QuitClosure());
client_->StartConnection(AppRemotingSharedData->user_name(),
AppRemotingSharedData->access_token(),
......@@ -248,7 +248,7 @@ void AppRemotingConnectedClientFixture::HandleOnWindowAddedMessage(
// Now that the main window is visible, give the app some time to settle
// before signaling that it is ready to run tests.
timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(2),
run_loop_->QuitClosure());
run_loop_->QuitClosure());
}
}
......
......@@ -40,16 +40,17 @@ std::string GetAuthorizationCodeUri() {
bool use_plus = true;
return base::StringPrintf(
"https://accounts.google.com/o/oauth2/auth"
"?scope=%s"
"&redirect_uri=https://chromoting-oauth.talkgadget.google.com/"
"talkgadget/oauth/chrome-remote-desktop/dev"
"&response_type=code"
"&client_id=%s"
"&access_type=offline"
"&approval_prompt=force",
"?scope=%s"
"&redirect_uri=https://chromoting-oauth.talkgadget.google.com/"
"talkgadget/oauth/chrome-remote-desktop/dev"
"&response_type=code"
"&client_id=%s"
"&access_type=offline"
"&approval_prompt=force",
net::EscapeUrlEncodedData(kAppRemotingAuthScopeValues, use_plus).c_str(),
net::EscapeUrlEncodedData(google_apis::GetOAuth2ClientID(
google_apis::CLIENT_REMOTING), use_plus).c_str());
net::EscapeUrlEncodedData(
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING),
use_plus).c_str());
}
void PrintUsage() {
......@@ -69,12 +70,14 @@ void PrintUsage() {
switches::kHelpSwitchName);
printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n",
switches::kServiceEnvironmentSwitchName);
printf(" %s: Retrieves and displays the connection status for all known "
"hosts, no tests will be run\n",
switches::kShowHostAvailabilitySwitchName);
printf(" %s: Specifies the optional logging level of the tool (0-3)."
" [default: off]\n",
switches::kLoggingLevelSwitchName);
printf(
" %s: Retrieves and displays the connection status for all known "
"hosts, no tests will be run\n",
switches::kShowHostAvailabilitySwitchName);
printf(
" %s: Specifies the optional logging level of the tool (0-3)."
" [default: off]\n",
switches::kLoggingLevelSwitchName);
}
void PrintAuthCodeInfo() {
......@@ -93,18 +96,20 @@ void PrintAuthCodeInfo() {
printf("\n has been revoked or expired.\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"
" - Open the Authorization URL link shown below in your browser\n"
" - Approve the requested permissions for the tool\n"
" - Copy the 'code' value in the redirected URL\n"
" - Run the tool and pass in copied auth code as a parameter\n");
printf(
"\nFollow these steps to produce an auth code:\n"
" - Open the Authorization URL link shown below in your browser\n"
" - Approve the requested permissions for the tool\n"
" - Copy the 'code' value in the redirected URL\n"
" - Run the tool and pass in copied auth code as a parameter\n");
printf("\nAuthorization URL:\n");
printf("%s\n", GetAuthorizationCodeUri().c_str());
printf("\nRedirected URL Example:\n");
printf("https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/"
"chrome-remote-desktop/dev?code=4/AKtf...\n");
printf(
"https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/"
"chrome-remote-desktop/dev?code=4/AKtf...\n");
printf("\nTool usage example with the newly created auth code:\n");
printf("ar_test_driver --%s=example@gmail.com --%s=4/AKtf...\n\n",
......
......@@ -142,8 +142,8 @@ void AppRemotingTestDriverEnvironment::ShowHostAvailability() {
while (it != application_names_.end()) {
std::string application_name = *it;
const RemoteApplicationDetails& application_details = GetDetailsFromAppName(
application_name);
const RemoteApplicationDetails& application_details =
GetDetailsFromAppName(application_name);
RemoteHostInfo remote_host_info;
GetRemoteHostInfoForApplicationId(application_details.application_id,
......
......@@ -26,15 +26,13 @@ using testing::_;
// file system dependencies when testing the TestDriverEnvironment.
class FakeRefreshTokenStore : public RefreshTokenStore {
public:
FakeRefreshTokenStore() :
refresh_token_value(kRefreshTokenValue),
refresh_token_write_succeeded(true),
refresh_token_write_attempted(false) {}
FakeRefreshTokenStore()
: refresh_token_value(kRefreshTokenValue),
refresh_token_write_succeeded(true),
refresh_token_write_attempted(false) {}
~FakeRefreshTokenStore() override {}
std::string FetchRefreshToken() override {
return refresh_token_value;
};
std::string FetchRefreshToken() override { return refresh_token_value; };
bool StoreRefreshToken(const std::string& refresh_token) override {
// Record the information passed to us to write.
......@@ -70,9 +68,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -83,10 +80,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCode) {
EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
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.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0);
kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors.
init_result = environment_object.Initialize(kAuthCodeValue);
......@@ -112,9 +111,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithAuthCodeFailed) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -140,9 +138,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) {
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -160,7 +157,8 @@ TEST(AppRemotingTestDriverEnvironmentTest, InitializeObjectWithRefreshToken) {
// Verify the object was initialized correctly.
EXPECT_EQ(environment_object.user_name().compare(kUserNameValue), 0);
EXPECT_EQ(environment_object.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0);
kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors.
init_result = environment_object.Initialize(std::string());
......@@ -187,9 +185,8 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -218,9 +215,8 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -252,9 +248,8 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(0);
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -284,13 +279,12 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromAuthCode(_, _))
.Times(1);
EXPECT_CALL(mock_access_token_fetcher,
GetAccessTokenFromRefreshToken(_, _)).Times(1);
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(1);
}
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -301,10 +295,12 @@ TEST(AppRemotingTestDriverEnvironmentTest,
EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
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.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0);
kFakeAccessTokenFetcherAccessTokenValue),
0);
// Attempt to init again, we should not see any additional calls or errors.
bool refresh_result = environment_object.RefreshAccessToken();
......@@ -331,13 +327,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) {
.Times(1);
// Mock is set up for this call to fail.
EXPECT_CALL(mock_access_token_fetcher,
GetAccessTokenFromRefreshToken(_, _)).Times(1);
EXPECT_CALL(mock_access_token_fetcher, GetAccessTokenFromRefreshToken(_, _))
.Times(1);
}
AppRemotingTestDriverEnvironment environment_object(
kUserNameValue,
kDeveloperEnvironment);
AppRemotingTestDriverEnvironment environment_object(kUserNameValue,
kDeveloperEnvironment);
environment_object.SetAccessTokenFetcherForTest(&mock_access_token_fetcher);
......@@ -348,10 +343,12 @@ TEST(AppRemotingTestDriverEnvironmentTest, RefreshAccessTokenFailure) {
EXPECT_TRUE(init_result);
EXPECT_TRUE(fake_token_store.refresh_token_write_attempted);
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.access_token().compare(
kFakeAccessTokenFetcherAccessTokenValue), 0);
kFakeAccessTokenFetcherAccessTokenValue),
0);
fake_access_token_fetcher->set_fail_access_token_from_refresh_token(true);
......
......@@ -7,12 +7,13 @@
namespace remoting {
namespace test {
FakeAccessTokenFetcher::FakeAccessTokenFetcher() :
fail_access_token_from_auth_code_(false),
fail_access_token_from_refresh_token_(false) {}
FakeAccessTokenFetcher::~FakeAccessTokenFetcher() {}
FakeAccessTokenFetcher::FakeAccessTokenFetcher()
: fail_access_token_from_auth_code_(false),
fail_access_token_from_refresh_token_(false) {
}
FakeAccessTokenFetcher::~FakeAccessTokenFetcher() {
}
void FakeAccessTokenFetcher::GetAccessTokenFromAuthCode(
const std::string& auth_code,
......
......@@ -24,9 +24,8 @@ class FakeAccessTokenFetcher : public AccessTokenFetcher {
~FakeAccessTokenFetcher() override;
// AccessTokenFetcher interface.
void GetAccessTokenFromAuthCode(
const std::string& auth_code,
const AccessTokenCallback& callback) override;
void GetAccessTokenFromAuthCode(const std::string& auth_code,
const AccessTokenCallback& callback) override;
void GetAccessTokenFromRefreshToken(
const std::string& refresh_token,
const AccessTokenCallback& callback) override;
......
......@@ -7,10 +7,12 @@
namespace remoting {
namespace test {
FakeRemoteHostInfoFetcher::FakeRemoteHostInfoFetcher() :
fail_retrieve_remote_host_info_(false) {}
FakeRemoteHostInfoFetcher::FakeRemoteHostInfoFetcher()
: fail_retrieve_remote_host_info_(false) {
}
FakeRemoteHostInfoFetcher::~FakeRemoteHostInfoFetcher() {}
FakeRemoteHostInfoFetcher::~FakeRemoteHostInfoFetcher() {
}
bool FakeRemoteHostInfoFetcher::RetrieveRemoteHostInfo(
const std::string& application_id,
......
......@@ -21,11 +21,10 @@ class FakeRemoteHostInfoFetcher : public RemoteHostInfoFetcher {
~FakeRemoteHostInfoFetcher() override;
// RemoteHostInfoFetcher interface.
bool RetrieveRemoteHostInfo(
const std::string& application_id,
const std::string& access_token,
ServiceEnvironment service_environment,
const RemoteHostInfoCallback& callback) override;
bool RetrieveRemoteHostInfo(const std::string& application_id,
const std::string& access_token,
ServiceEnvironment service_environment,
const RemoteHostInfoCallback& callback) override;
void set_fail_retrieve_remote_host_info(bool fail) {
fail_retrieve_remote_host_info_ = fail;
......
......@@ -20,12 +20,13 @@ void MockAccessTokenFetcher::SetAccessTokenFetcher(
scoped_ptr<AccessTokenFetcher> fetcher) {
internal_access_token_fetcher_ = fetcher.Pass();
ON_CALL(*this, GetAccessTokenFromAuthCode(_, _)).WillByDefault(
Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromAuthCode));
ON_CALL(*this, GetAccessTokenFromRefreshToken(_, _)).WillByDefault(
Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromRefreshToken));
ON_CALL(*this, GetAccessTokenFromAuthCode(_, _))
.WillByDefault(Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromAuthCode));
ON_CALL(*this, GetAccessTokenFromRefreshToken(_, _))
.WillByDefault(
Invoke(internal_access_token_fetcher_.get(),
&AccessTokenFetcher::GetAccessTokenFromRefreshToken));
}
} // namespace test
......
......@@ -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(
kRefreshTokenStoreFolder);
refresh_token_dir_path =
refresh_token_dir_path.Append(kRefreshTokenStoreFolder);
// 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
......@@ -58,10 +58,12 @@ class RefreshTokenStoreOnDisk : public RefreshTokenStore {
DISALLOW_COPY_AND_ASSIGN(RefreshTokenStoreOnDisk);
};
RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name) :
user_name_(user_name) {}
RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name)
: user_name_(user_name) {
}
RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {}
RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {
}
std::string RefreshTokenStoreOnDisk::FetchRefreshToken() {
base::FilePath token_dir_path(GetRefreshTokenDirPath(user_name_));
......@@ -131,8 +133,8 @@ bool RefreshTokenStoreOnDisk::StoreRefreshToken(
scoped_ptr<RefreshTokenStore> RefreshTokenStore::OnDisk(
const std::string& user_name) {
return make_scoped_ptr<RefreshTokenStore>(new RefreshTokenStoreOnDisk(
user_name));
return make_scoped_ptr<RefreshTokenStore>(
new RefreshTokenStoreOnDisk(user_name));
}
} // namespace test
......
......@@ -9,10 +9,12 @@
namespace remoting {
namespace test {
RemoteHostInfo::RemoteHostInfo() :
remote_host_status(kRemoteHostStatusUnknown) {}
RemoteHostInfo::RemoteHostInfo()
: remote_host_status(kRemoteHostStatusUnknown) {
}
RemoteHostInfo::~RemoteHostInfo() {}
RemoteHostInfo::~RemoteHostInfo() {
}
bool RemoteHostInfo::IsReadyForConnection() const {
return (remote_host_status == kRemoteHostStatusReady);
......
......@@ -11,9 +11,9 @@ namespace remoting {
namespace test {
enum RemoteHostStatus {
kRemoteHostStatusReady,
kRemoteHostStatusPending,
kRemoteHostStatusUnknown
kRemoteHostStatusReady,
kRemoteHostStatusPending,
kRemoteHostStatusUnknown
};
// Holds the information needed to establish a connection with a remote host.
......
......@@ -43,25 +43,23 @@ namespace test {
// necessary, for use by the RemoteHostInfoFetcher.
class RemoteHostInfoFetcherTest : public ::testing::Test {
public:
RemoteHostInfoFetcherTest() :
url_fetcher_factory_(nullptr) {}
RemoteHostInfoFetcherTest() : url_fetcher_factory_(nullptr) {}
~RemoteHostInfoFetcherTest() override {}
// Used as a RemoteHostInfoCallback for testing.
void OnRemoteHostInfoRetrieved(
base::Closure done_closure,
const RemoteHostInfo& retrieved_remote_host_info);
base::Closure done_closure,
const RemoteHostInfo& retrieved_remote_host_info);
protected:
// testing::Test interface.
void SetUp() override;
// Sets the HTTP status and data returned for a specified URL.
void SetFakeResponse(
const GURL& url,
const std::string& data,
net::HttpStatusCode code,
net::URLRequestStatus::Status status);
void SetFakeResponse(const GURL& url,
const std::string& data,
net::HttpStatusCode code,
net::URLRequestStatus::Status status);
// Used for result verification.
RemoteHostInfo remote_host_info_;
......@@ -92,13 +90,11 @@ void RemoteHostInfoFetcherTest::SetUp() {
message_loop_.reset(new base::MessageLoopForIO);
}
dev_service_environment_url_ = base::StringPrintf(
kDevServiceEnvironmentUrlFormat,
kTestApplicationId);
dev_service_environment_url_ =
base::StringPrintf(kDevServiceEnvironmentUrlFormat, kTestApplicationId);
test_service_environment_url_ = base::StringPrintf(
kTestServiceEnvironmentUrlFormat,
kTestApplicationId);
test_service_environment_url_ =
base::StringPrintf(kTestServiceEnvironmentUrlFormat, kTestApplicationId);
}
void RemoteHostInfoFetcherTest::SetFakeResponse(
......@@ -110,29 +106,22 @@ void RemoteHostInfoFetcherTest::SetFakeResponse(
}
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) {
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(
GURL(test_service_environment_url_),
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(test_service_environment_url_),
kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kDeveloperEnvironment,
kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
remote_host_info_callback);
run_loop.Run();
......@@ -147,29 +136,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromDev) {
}
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoFromTest) {
SetFakeResponse(
GURL(test_service_environment_url_),
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
SetFakeResponse(GURL(test_service_environment_url_),
kRemoteHostInfoReadyResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kTestingEnvironment,
kTestApplicationId, kAccessTokenValue, kTestingEnvironment,
remote_host_info_callback);
run_loop.Run();
......@@ -187,37 +169,29 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoInvalidEnvironment) {
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kUnknownEnvironment,
kTestApplicationId, kAccessTokenValue, kUnknownEnvironment,
remote_host_info_callback);
EXPECT_FALSE(request_started);
}
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) {
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse, net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kDeveloperEnvironment,
kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
remote_host_info_callback);
run_loop.Run();
......@@ -235,23 +209,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoNetworkError) {
}
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) {
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoPendingResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoPendingResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kDeveloperEnvironment,
kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
remote_host_info_callback);
run_loop.Run();
......@@ -269,23 +238,18 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoPendingResponse) {
}
TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) {
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
base::RunLoop run_loop;
RemoteHostInfoCallback remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
run_loop.QuitClosure());
base::Unretained(this), run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kDeveloperEnvironment,
kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
remote_host_info_callback);
run_loop.Run();
......@@ -304,29 +268,22 @@ TEST_F(RemoteHostInfoFetcherTest, RetrieveRemoteHostInfoEmptyResponse) {
TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) {
// First, we will fetch info from the development service environment.
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(
GURL(test_service_environment_url_),
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoReadyResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(test_service_environment_url_),
kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
base::RunLoop dev_run_loop;
RemoteHostInfoCallback dev_remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
dev_run_loop.QuitClosure());
base::Unretained(this), dev_run_loop.QuitClosure());
RemoteHostInfoFetcher remote_host_info_fetcher;
bool dev_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kDeveloperEnvironment,
kTestApplicationId, kAccessTokenValue, kDeveloperEnvironment,
dev_remote_host_info_callback);
dev_run_loop.Run();
......@@ -340,32 +297,25 @@ TEST_F(RemoteHostInfoFetcherTest, MultipleRetrieveRemoteHostInfoRequests) {
EXPECT_TRUE(!remote_host_info_.shared_secret.empty());
// Next, we will fetch info from the test service environment.
SetFakeResponse(
GURL(test_service_environment_url_),
kRemoteHostInfoReadyResponse,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(
GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse,
net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
SetFakeResponse(GURL(test_service_environment_url_),
kRemoteHostInfoReadyResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
SetFakeResponse(GURL(dev_service_environment_url_),
kRemoteHostInfoEmptyResponse, net::HTTP_NOT_FOUND,
net::URLRequestStatus::FAILED);
base::RunLoop test_run_loop;
RemoteHostInfoCallback test_remote_host_info_callback =
base::Bind(&RemoteHostInfoFetcherTest::OnRemoteHostInfoRetrieved,
base::Unretained(this),
test_run_loop.QuitClosure());
base::Unretained(this), test_run_loop.QuitClosure());
// Reset the state of our internal |remote_host_info_| object.
remote_host_info_ = RemoteHostInfo();
EXPECT_FALSE(remote_host_info_.IsReadyForConnection());
bool test_request_started = remote_host_info_fetcher.RetrieveRemoteHostInfo(
kTestApplicationId,
kAccessTokenValue,
kTestingEnvironment,
kTestApplicationId, kAccessTokenValue, kTestingEnvironment,
test_remote_host_info_callback);
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