OLD | NEW |
(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() { |
| 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", GURL("https://fake.com/fake.png"), 0.
9}); |
| 22 res.push_back(InterestsFetcher::Interest{"Google Chrome", |
| 23 GURL("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() {} |
| 32 }; |
| 33 |
| 34 TEST_F(InterestsServiceTest, ConvertEmptyResponse) { |
| 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 } |
OLD | NEW |