Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2464)

Unified Diff: chrome/browser/interests/interests_fetcher_unittest.cc

Issue 1396443002: Add the JNI code in order to let Java use the InterestsFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/interests/interests_fetcher_unittest.cc
diff --git a/chrome/browser/interests/interests_fetcher_unittest.cc b/chrome/browser/interests/interests_fetcher_unittest.cc
index 8449d15deaa87e355d4505dff62627be7347383b..7e71f9691b1276997e86a9c69503b9e57bef6e5e 100644
--- a/chrome/browser/interests/interests_fetcher_unittest.cc
+++ b/chrome/browser/interests/interests_fetcher_unittest.cc
@@ -78,9 +78,22 @@ class InterestsFetcherTest : public testing::Test {
command_line->AppendSwitchASCII(switches::kInterestsURL, kInterestsURL);
}
- MOCK_METHOD1(OnReceivedInterests,
- void(const std::vector<InterestsFetcher::Interest>&));
-
+ MOCK_METHOD0(OnSuccessfulResponse, void());
+ MOCK_METHOD0(OnEmptyResponse, void());
+ MOCK_METHOD0(OnFailedResponse, void());
+
+ void OnReceivedInterests(
+ scoped_ptr<std::vector<InterestsFetcher::Interest>> interests) {
+
+ if (interests) {
Bernhard Bauer 2015/10/08 09:04:41 Early-return if (!interests)?
PEConn 2015/10/08 09:40:56 Done.
+ if (*interests == GetExpectedEmptyResponse())
+ OnEmptyResponse();
+ else if (*interests == GetExpectedSuccessfulResponse())
+ OnSuccessfulResponse();
Bernhard Bauer 2015/10/08 09:04:41 Add an additional else that fails the test, in cas
PEConn 2015/10/08 09:40:56 Done.
+ } else {
+ OnFailedResponse();
+ }
+ }
protected:
void RequestInterests() {
request_.reset(new InterestsFetcher(&token_service_,
@@ -140,39 +153,39 @@ class InterestsFetcherTest : public testing::Test {
TEST_F(InterestsFetcherTest, EmptyResponse) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse()));
+ EXPECT_CALL(*this, OnEmptyResponse());
IssueAccessTokens();
SendValidResponse(kEmptyResponse);
}
TEST_F(InterestsFetcherTest, SuccessfullResponse) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedSuccessfulResponse()));
+ EXPECT_CALL(*this, OnSuccessfulResponse());
IssueAccessTokens();
SendValidResponse(kSuccessfulResponse);
}
TEST_F(InterestsFetcherTest, FailedResponse) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse()));
+ EXPECT_CALL(*this, OnFailedResponse());
IssueAccessTokens();
SendFailedResponse();
}
TEST_F(InterestsFetcherTest, FailedOAuthRequest) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse()));
+ EXPECT_CALL(*this, OnFailedResponse());
IssueAccessTokenErrors();
}
TEST_F(InterestsFetcherTest, RetryOnAuthorizationError) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse())).Times(0);
+ EXPECT_CALL(*this, OnEmptyResponse()).Times(0);
IssueAccessTokens();
SendAuthorizationError();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse()));
+ EXPECT_CALL(*this, OnEmptyResponse());
IssueAccessTokens();
SendValidResponse(kEmptyResponse);
}
@@ -180,11 +193,11 @@ TEST_F(InterestsFetcherTest, RetryOnAuthorizationError) {
TEST_F(InterestsFetcherTest, RetryOnlyOnceOnAuthorizationError) {
RequestInterests();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse())).Times(0);
+ EXPECT_CALL(*this, OnEmptyResponse()).Times(0);
IssueAccessTokens();
SendAuthorizationError();
- EXPECT_CALL(*this, OnReceivedInterests(GetExpectedEmptyResponse()));
+ EXPECT_CALL(*this, OnFailedResponse());
IssueAccessTokens();
SendAuthorizationError();
}

Powered by Google App Engine
This is Rietveld 408576698