blob: 2490a0317f07cfd0dce408da65fc9bfeff11a1de [file] [log] [blame]
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @exportToFramework:skipFile()
package androidx.appsearch.cts.app;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.appsearch.app.AppSearchSession;
import androidx.appsearch.platformstorage.PlatformStorage;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.filters.SdkSuppress;
import com.google.common.util.concurrent.ListenableFuture;
import org.junit.Test;
import java.util.concurrent.ExecutorService;
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
public class AppSearchSessionPlatformCtsTest extends AppSearchSessionCtsTestBase {
@Override
protected ListenableFuture<AppSearchSession> createSearchSession(@NonNull String dbName) {
Context context = ApplicationProvider.getApplicationContext();
return PlatformStorage.createSearchSession(
new PlatformStorage.SearchContext.Builder(context, dbName).build());
}
@Override
protected ListenableFuture<AppSearchSession> createSearchSession(
@NonNull String dbName, @NonNull ExecutorService executor) {
Context context = ApplicationProvider.getApplicationContext();
return PlatformStorage.createSearchSession(
new PlatformStorage.SearchContext.Builder(context, dbName)
.setWorkerExecutor(executor).build());
}
@Test
public void testCapabilities() throws Exception {
Context context = ApplicationProvider.getApplicationContext();
AppSearchSession db2 = PlatformStorage.createSearchSession(
new PlatformStorage.SearchContext.Builder(context, DB_NAME_2).build()).get();
// TODO(b/201316758) Update to reflect support in Android T+ once this feature is synced
// over into service-appsearch.
assertThat(db2.getCapabilities().isSubmatchSupported()).isFalse();
}
}