Chromium Code Reviews| 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..82995131b37d5854fdcf9fad99e659c77f5e19b0 |
| --- /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() { |
|
Bernhard Bauer
2015/09/29 14:04:05
Add an empty line before this one.
PEConn
2015/10/07 13:55:21
Done.
|
| + 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() {} |
|
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
|
| +}; |
| + |
| +TEST_F(InterestsServiceTest, ConvertEmptyResponse) { |
|
Bernhard Bauer
2015/09/29 14:04:05
These tests don't seem to test much more than the
|
| + 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)); |
| +} |