| 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..ae9fb41b9d7f3743be40681b1fc4cf85a817d082
|
| --- /dev/null
|
| +++ b/chrome/browser/android/interests_service_unittest.cc
|
| @@ -0,0 +1,46 @@
|
| +// 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", GURL("https://fake.com/fake.png"), 0.9});
|
| + res.push_back(InterestsFetcher::Interest{"Google Chrome",
|
| + GURL("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());
|
| + EXPECT_EQ(0, env->GetArrayLength(j_interests));
|
| +}
|
| +
|
| +TEST_F(InterestsServiceTest, ConvertSucccesfulResponse) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + jobjectArray j_interests =
|
| + InterestsService::ConvertInterestsToJava(GetSuccessfulResponse());
|
| + EXPECT_EQ(2, env->GetArrayLength(j_interests));
|
| +}
|
|
|