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

Side by Side Diff: chrome/browser/android/interests_service_unittest.cc

Issue 1334233003: Add the JNI code in order to let Java use the InterestsFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntp-interests-retriever
Patch Set: The access_token is obtained in the native code. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <jni.h>
6
7 #include "base/android/jni_android.h"
8 #include "chrome/browser/android/interests_service.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 using base::android::AttachCurrentThread;
12
13 namespace {
14 std::vector<InterestsFetcher::Interest> GetEmptyResponse() {
Bernhard Bauer 2015/09/29 14:04:05 Add an empty line before this one.
PEConn 2015/10/07 13:55:21 Done.
15 return std::vector<InterestsFetcher::Interest>();
16 }
17
18 std::vector<InterestsFetcher::Interest> GetSuccessfulResponse() {
19 std::vector<InterestsFetcher::Interest> res;
20 res.push_back(
21 InterestsFetcher::Interest{"Google", "https://fake.com/fake.png", 0.9});
22 res.push_back(InterestsFetcher::Interest{"Google Chrome",
23 "https://fake.com/fake.png", 0.98});
24 return res;
25 }
26
27 } // namespace
28
29 class InterestsServiceTest : public testing::Test {
30 public:
31 InterestsServiceTest() {}
Bernhard Bauer 2015/09/29 14:04:05 This isn't actually necessary -- the class will ge
Marc Treib 2015/10/06 13:33:57 Actually, the whole class isn't necessary right no
32 };
33
34 TEST_F(InterestsServiceTest, ConvertEmptyResponse) {
Bernhard Bauer 2015/09/29 14:04:05 These tests don't seem to test much more than the
35 JNIEnv* env = AttachCurrentThread();
36 jobjectArray j_interests =
37 InterestsService::ConvertInterestsToJava(GetEmptyResponse());
38 EXPECT_EQ(0, env->GetArrayLength(j_interests));
39 }
40
41 TEST_F(InterestsServiceTest, ConvertSucccesfulResponse) {
42 JNIEnv* env = AttachCurrentThread();
43 jobjectArray j_interests =
44 InterestsService::ConvertInterestsToJava(GetSuccessfulResponse());
45 EXPECT_EQ(2, env->GetArrayLength(j_interests));
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698