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

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
« no previous file with comments | « chrome/browser/interests/interests_fetcher.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ec67a18b13dfaac0e689bfb7fd9b036fcc618190 100644
--- a/chrome/browser/interests/interests_fetcher_unittest.cc
+++ b/chrome/browser/interests/interests_fetcher_unittest.cc
@@ -78,8 +78,24 @@ 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) {
+ OnFailedResponse();
+ return;
+ }
+
+ if (*interests == GetExpectedEmptyResponse())
+ OnEmptyResponse();
+ else if (*interests == GetExpectedSuccessfulResponse())
+ OnSuccessfulResponse();
+ else
+ FAIL() << "Unexpected interests response.";
+ }
protected:
void RequestInterests() {
@@ -140,39 +156,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 +196,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();
}
« no previous file with comments | « chrome/browser/interests/interests_fetcher.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698