-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade the target SDK in Android tests to version 34, which is recom…
…mended by Google Play. To do this, we need to use the PlatformTestStorage API to load test data. Otherwise the tests can't access the test data as normal file access are not permitted anymore. See: https://developer.android.com/google/play/requirements/target-sdk PiperOrigin-RevId: 668483337 Change-Id: I085a5ead8169d30fc61962d95eb81c645e870c18
- Loading branch information
1 parent
196de16
commit 4994f5c
Showing
7 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/google/crypto/tink/internal/testing/BuildDispatchedTestCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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 specified language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.google.crypto.tink.internal.testing; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Static testonly utility functions which need to be compiled with different code in Android and | ||
* Java. | ||
* | ||
* <p>This is the Java version. The android code can be found in | ||
* third_party/tink/java_src/src_android/main/java/com/google/crypto/tink/internal/testing/BuildDispatchedTestCode.java | ||
*/ | ||
final class BuildDispatchedTestCode { | ||
|
||
private BuildDispatchedTestCode() {} | ||
|
||
public static InputStream openInputFile(String pathname) throws FileNotFoundException { | ||
return new FileInputStream(new File(pathname)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src_android/main/java/com/google/crypto/tink/internal/testing/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@build_bazel_rules_android//android:rules.bzl", "android_library") | ||
|
||
licenses(["notice"]) | ||
|
||
package( | ||
default_testonly = 1, | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
android_library( | ||
name = "build_dispatched_test_code-android", | ||
testonly = 1, | ||
srcs = ["BuildDispatchedTestCode.java"], | ||
deps = ["@maven//:androidx_test_monitor"], | ||
) |
37 changes: 37 additions & 0 deletions
37
src_android/main/java/com/google/crypto/tink/internal/testing/BuildDispatchedTestCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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 specified language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.google.crypto.tink.internal.testing; | ||
|
||
import androidx.test.platform.io.PlatformTestStorageRegistry; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Static testonly utility functions which need to be compiled with different code in Android and | ||
* Java. | ||
* | ||
* <p>This is the Android version. The Java code can be found in | ||
* third_party/tink/java_src/src/main/java/com/google/crypto/tink/internal/testing/BuildDispatchedTestCode.java | ||
*/ | ||
final class BuildDispatchedTestCode { | ||
|
||
private BuildDispatchedTestCode() {} | ||
|
||
public static InputStream openInputFile(String pathname) throws FileNotFoundException { | ||
return PlatformTestStorageRegistry.getInstance().openInputFile("google3/" + pathname); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters