| Index: chrome/browser/android/interests_service_unittest.cc
|
| diff --git a/chrome/browser/android/interests_service_unittest.cc b/chrome/browser/android/interests_service_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1c1bc4e26344da42793468c729c5441fcc310de5
|
| --- /dev/null
|
| +++ b/chrome/browser/android/interests_service_unittest.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <jni.h>
|
| +
|
| +#include "base/android/jni_android.h"
|
| +#include "chrome/browser/android/interests_service.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +using base::android::AttachCurrentThread;
|
| +
|
| +namespace {
|
| +std::vector<InterestsFetcher::Interest> GetEmptyResponse() {
|
| + return std::vector<InterestsFetcher::Interest>();
|
| +}
|
| +
|
| +std::vector<InterestsFetcher::Interest> GetSuccessfulResponse() {
|
| + std::vector<InterestsFetcher::Interest> res;
|
| + res.push_back(
|
| + InterestsFetcher::Interest{"Google", "https://fake.com/fake.png", 0.9});
|
| + res.push_back(InterestsFetcher::Interest{
|
| + "Google Chrome", "https://fake.com/fake.png", 0.98});
|
| + return res;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +class InterestsServiceTest: public testing::Test {
|
| + public:
|
| + InterestsServiceTest(){
|
| + }
|
| +
|
| +};
|
| +
|
| +TEST_F(InterestsServiceTest, ConvertEmptyResponse) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + jobjectArray j_interests =
|
| + InterestsService::ConvertInterestsToJava(GetEmptyResponse());
|
| + CHECK_EQ(env->GetArrayLength(j_interests), 0);
|
| +}
|
| +
|
| +TEST_F(InterestsServiceTest, ConvertSucccesfulResponse) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + jobjectArray j_interests =
|
| + InterestsService::ConvertInterestsToJava(GetSuccessfulResponse());
|
| + CHECK_EQ(env->GetArrayLength(j_interests), 2);
|
| +}
|
|
|