1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // This is a shared test between icu and javaicu calendar implementations. 18 // It is meant to be #include'd. 19 20 #ifndef LIBTEXTCLASSIFIER_UTILS_CALENDAR_CALENDAR_TEST_INCLUDE_H_ 21 #define LIBTEXTCLASSIFIER_UTILS_CALENDAR_CALENDAR_TEST_INCLUDE_H_ 22 23 #if defined TC3_CALENDAR_ICU 24 #include "utils/calendar/calendar-icu.h" 25 #define TC3_TESTING_CREATE_CALENDARLIB_INSTANCE(VAR) VAR() 26 #elif defined TC3_CALENDAR_JAVAICU 27 #include <jni.h> 28 extern JNIEnv* g_jenv; 29 #define TC3_TESTING_CREATE_CALENDARLIB_INSTANCE(VAR) \ 30 VAR(JniCache::Create(g_jenv)) 31 #include "utils/calendar/calendar-javaicu.h" 32 #else 33 #error Unsupported calendar implementation. 34 #endif 35 #include "utils/base/logging.h" 36 37 #include "gtest/gtest.h" 38 39 // This can get overridden in the javaicu version which needs to pass an JNIEnv* 40 // argument to the constructor. 41 #ifndef TC3_TESTING_CREATE_CALENDARLIB_INSTANCE 42 43 #endif 44 45 namespace libtextclassifier3 { 46 namespace test_internal { 47 48 class CalendarTest : public ::testing::Test { 49 protected: CalendarTest()50 CalendarTest() : TC3_TESTING_CREATE_CALENDARLIB_INSTANCE(calendarlib_) {} 51 CalendarLib calendarlib_; 52 }; 53 54 } // namespace test_internal 55 } // namespace libtextclassifier3 56 57 #endif // LIBTEXTCLASSIFIER_UTILS_CALENDAR_CALENDAR_TEST_INCLUDE_H_ 58