653 Commits

Author SHA1 Message Date
Paul Duffin
19290e456f Merge "Clean up TestCaseUtil" am: 43851d01d8 am: e38d503394 am: b5b6e7cf45
am: ad654a3af5

Change-Id: Idd36689c3a90728ee543be0ffa7457fe79b66ba3
2017-06-26 09:50:09 +00:00
Paul Duffin
ad654a3af5 Merge "Clean up TestCaseUtil" am: 43851d01d8 am: e38d503394
am: b5b6e7cf45

Change-Id: I98265e973df1bf7ac28b7f79f6ccd0a865762304
2017-06-26 09:41:44 +00:00
Paul Duffin
b5b6e7cf45 Merge "Clean up TestCaseUtil" am: 43851d01d8
am: e38d503394

Change-Id: I62a80b405d05ec7b4da050bd6b01df4c965d6187
2017-06-26 09:33:23 +00:00
Seigo Nonaka
c25c3da8b6 Stop loading other package's font by default.
Since CONTEXT_RESTRICTED is not a default flag of createPackageContext,
we can't rely on it for preventing unexpected font injections.
To protect developers and existing apps from a risk of font injection,
stop loading font from other package's resouce unless the developer
explicitly set CONTEXT_IGNORE_SECURITY.

Bug: 62813533
Bug: 62879353
Test: Manually done
Merged-In: I4442ddc48dadb5c968b444be86038b602074d301
Change-Id: I4442ddc48dadb5c968b444be86038b602074d301
(cherry picked from commit 6d6cd68660635d670b0cb17f348b7c1da13704b3)
2017-06-23 12:27:23 +00:00
Seigo Nonaka
ba12631bba Merge "Stop loading other package's font by default." into oc-dev
am: 824d75e0e1

Change-Id: I5518dbd8b5d8a4548ea00bbfca0e3aee87880ee7
2017-06-23 04:23:44 +00:00
Seigo Nonaka
80f6a985c3 Stop loading other package's font by default.
Since CONTEXT_RESTRICTED is not a default flag of createPackageContext,
we can't rely on it for preventing unexpected font injections.
To protect developers and existing apps from a risk of font injection,
stop loading font from other package's resouce unless the developer
explicitly set CONTEXT_IGNORE_SECURITY.

This CL contains Iac2a6fb3d82ef23d5ca6ee33f4aaa9ed28455271 by manual
merging to handle repository split.

Bug: 62813533
Bug: 62879353
Test: Manually done
Merged-In: I4442ddc48dadb5c968b444be86038b602074d301
Change-Id: I4442ddc48dadb5c968b444be86038b602074d301
2017-06-22 19:07:17 -07:00
TreeHugger Robot
abc6fd57de Merge "Stop loading other package's font by default." 2017-06-22 22:28:10 +00:00
Paul Duffin
60184293e1 Merge "Merge "Ensure that android.test tests pass" am: 156775fea8 am: 34dc5a58b3 am: e211119fea" into oc-dr1-dev-plus-aosp
am: 989b7db027

Change-Id: I1e3bcb0b3607464ab2267c14ff2e8dcd96a19f56
2017-06-22 20:50:34 +00:00
Paul Duffin
aa7f42c5c1 Merge "Ensure that android.test tests pass" am: 156775fea8 am: 34dc5a58b3
am: e211119fea

Change-Id: I4692f9a86dae8bb2c5476eb477924230034cdd6b
2017-06-22 20:15:27 +00:00
Seigo Nonaka
6d6cd68660 Stop loading other package's font by default.
Since CONTEXT_RESTRICTED is not a default flag of createPackageContext,
we can't rely on it for preventing unexpected font injections.
To protect developers and existing apps from a risk of font injection,
stop loading font from other package's resouce unless the developer
explicitly set CONTEXT_IGNORE_SECURITY.

Bug: 62813533
Bug: 62879353
Test: Manually done
Change-Id: I4442ddc48dadb5c968b444be86038b602074d301
2017-06-22 08:36:03 -07:00
Paul Duffin
fedb4b7456 Clean up Predicate related code in android.test
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.

The HasClassAnnotation and HasMethodAnnotation were never used
separately and only used by HasAnnotation. This merges the functionality
into a single nested class in TestPredicates, hidden behind the new
TestPredicates.hasAnnotation(). The HasAnnotationTest was renamed as
TestPredicatesTest and the HasClassAnnotationTest and
HasMethodAnnotationTest classes were removed as their tests provide no
additional coverage. The removal of the Has*Annotation.java files means
that the test-runner/src/android/test/suitebuilder/annotation/ directory
is empty apart from the package.html file so that was moved to
legacy-test to sit alongside the actual annotation classes.

The Predicates class, while part of the legacy-test module was only
ever used by the test-runner module and only its not() method was
actually used. So, the not() method and associated nested class were
moved to TestPredicates, the tests for not() were moved to
TestPredicatesTest and the Predicates* classes were removed.
That allowed for the removal of the legacy-android-tests as that is now
empty.

TestPredicates has a number of constants that were public. They were
hidden by moving them to the class that actually used them.

A minor generic issue was fixed in AssignableFrom.

Bug: 30188076
Test: make checkbuild and run FrameworkTestRunnerTests
Change-Id: I861da388a4146bb28e1e480d1b7ba9137b7b270e
2017-06-22 15:48:44 +01:00
Paul Duffin
e211119fea Merge "Ensure that android.test tests pass" am: 156775fea8
am: 34dc5a58b3

Change-Id: I546ea542d0781f825e131eb94bc54e22adadfc4e
2017-06-22 14:39:08 +00:00
Paul Duffin
bd96f40808 Clean up TestCaseUtil
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.

TestCaseUtil.getTestCaseNames() is only used by tests but its tests did
provide some coverage of the getTests() method so remove the method and
the tests the method was simply moved into TestCaseUtilTest and the
tests renamed to make it clearer that they are testing
TestCaseUtil.getTests().

Similarly, TestCaseUtil.createTestSuite() was only used by tests but its
tests did provide some coverage of the invokeSuiteMethodIfPossible()
method so the tests were modified and renamed to preserve that coverage.

TestCaseUtil.getTestAtIndex() was completely unused so was just removed.

Bug: 30188076
Test: make checkbuild and ran FrameworkTestRunnerTests
Change-Id: I62bbdbab428d7560f0c7df11f313fe60cfd31d13
2017-06-22 15:21:32 +01:00
Paul Duffin
e24e60ecac Remove a.t.TestCase
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.

The android.test.TestCase class is only referenced from the
DatabasePerformanceTests class. There do not seem to be any references
to that class either and there is a NewDatabasePerformanceTests.java
file in the same directory that looks to be a JUnit based replacement.

Bug: 30188076
Test: make checkbuild and ran FrameworkTestRunnerTests
Change-Id: Iafb26dc98a40715244f07d1c9e05ada5b1602ebf
2017-06-22 15:21:11 +01:00
Paul Duffin
b3f83ae66b Removed a.t.TestRunner and cleanup a.t.TestPrinter
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.

The TestRunner class is not part of the API and is unused anywhere
within Android code (apart from one unused import which is in the
process of being removed) and in TestPrinter.

TestPrinter is not part of the API and its only use of TestRunner is to
implement the TestRunner.TestListener interface. It was safe to stop
TestPrinter from implementing TestRunner.TestListener because the latter
is only called from TestRunner which itself is never used. TestPrinter
was made package private as it is only used from the same package.

One the usages in TestPrinter were removed it was safe to remove
TestRunner.

Bug: 30188076
Test: make checkbuild and ran FrameworkTestRunnerTests
Change-Id: I0f4a6cf1fbec14c4778c6e09b8eabf822802774f
2017-06-22 15:17:26 +01:00
Paul Duffin
2a637cf9b0 Ensure that android.test tests pass
It looks as though the tests in test-runner/tests have not actually been
run successfully for over 7 years. As a result they have degraded. This
change fixes the tests so that they will pass and provides instructions
on how to run them.

TestCaseUtilTest.testGetTestCaseNamesForTestSuiteWithSuiteMethod
    This fails because it expected 2 names to be returned but only
    returns 0. The reason for that is although TwoTestsInTestSuite has a
    Test suite() method that does create a TestSuite with two tests the
    TestCaseUtil method does not actually call suite(). Instead, because
    TwoTestsInTestSuite is a TestSuite it just calls the tests() method
    on it which returns an empty Enumeration because TwoTestsInTestSuite
    is empty.

    The support for "static Test suite() {}" is broken but fixing this
    will affect the behavior of InstrumentationTestRunner which is used
    in thousands of different places both in and outside Google and so
    could cause untold problems.

TestSuiteBuilderTest.testIncludeAllPackagesUnderHere
    Reformat the list, one per line and then add missing name
    "testPublicConstructor".

ErrorTest/FailingTest
    These tests are not meant to be run on their own, only as part of a
    separate test. The RunAsPartOfSeparateTest annotation was added to
    allow these to be excluded using notAnnotation as shown in the
    instructions for running the tests.

Bug: 30188076
Test: followed new instructions in test-runner/tests/Android.mk
Change-Id: I60e7bee9cd08a9ab7777a2578fc58da772de5c1f
2017-06-22 12:58:58 +01:00
Paul Duffin
00d4d01c3a Merge "Remove android.test dependencies on a.o.PerformanceCollector" 2017-06-21 11:27:01 +00:00
Paul Duffin
d2cc32bcde Merge "Cleanup a.t.TestGrouping" am: 01dcf54e9a am: e6ac3a4efc
am: e2744c2705

Change-Id: I3493057c8362733f117dbc25f654497b9f22f219
2017-06-21 09:24:58 +00:00
Paul Duffin
e2744c2705 Merge "Cleanup a.t.TestGrouping" am: 01dcf54e9a
am: e6ac3a4efc

Change-Id: Id41ba23de38e5131460cad283fd5d7bea66d2156
2017-06-21 09:18:01 +00:00
Treehugger Robot
01dcf54e9a Merge "Cleanup a.t.TestGrouping" 2017-06-21 09:03:29 +00:00
Paul Duffin
37bd29af88 Merge "Remove unused a.t.InstrumentationUtils" am: 0e4f1358d6 am: 08c12d21f5
am: b4621a4072

Change-Id: I76b035a84dd184b2ff92fc175df383bc9983f616
2017-06-21 08:32:18 +00:00
Paul Duffin
e1b439a06d Merge "Cleanup a.t.InstrumentationTestRunner" am: 9d5576e081 am: 66b8ef6615
am: 4d7e8fb79e

Change-Id: I6d1de1dcb677e6c2c85c75fe8c5166b07cf713dd
2017-06-21 08:29:30 +00:00
Paul Duffin
d1d3d0fcfc Merge "Remove unused a.t.s.InstrumentationTestSuiteBuilder" am: 1935dce8eb am: a4d2464189
am: 28600f2cae

Change-Id: I9004d50829d18736f6d50f6bd48cb6d7c3b6e605
2017-06-21 08:20:29 +00:00
Paul Duffin
b4621a4072 Merge "Remove unused a.t.InstrumentationUtils" am: 0e4f1358d6
am: 08c12d21f5

Change-Id: I46ab06228623aa4e350b1285761e062e1d7393c0
2017-06-21 08:16:42 +00:00
Paul Duffin
4d7e8fb79e Merge "Cleanup a.t.InstrumentationTestRunner" am: 9d5576e081
am: 66b8ef6615

Change-Id: I3ca3f23c2f8a741daf867aad08f57bac373e5d91
2017-06-21 08:13:05 +00:00
Paul Duffin
4aef87575c Merge "Remove unused android.test.DatabaseTestUtils" am: 3724e7e5e9 am: e6e0601862
am: f18dd720d3

Change-Id: I06d4ce8bf1b5ea985c5deda2e2d0fe5b1e7d79e5
2017-06-21 08:12:05 +00:00
Paul Duffin
28600f2cae Merge "Remove unused a.t.s.InstrumentationTestSuiteBuilder" am: 1935dce8eb
am: a4d2464189

Change-Id: I88278d5cfd8fc3466cce39de3de54e34d67cbe0f
2017-06-21 08:07:14 +00:00
Paul Duffin
f18dd720d3 Merge "Remove unused android.test.DatabaseTestUtils" am: 3724e7e5e9
am: e6e0601862

Change-Id: I2c5e4c7af30893d9183ee35326814fcb4506d0e8
2017-06-21 08:03:56 +00:00
Paul Duffin
0e4f1358d6 Merge "Remove unused a.t.InstrumentationUtils" 2017-06-21 07:46:41 +00:00
Paul Duffin
9d5576e081 Merge "Cleanup a.t.InstrumentationTestRunner" 2017-06-21 07:46:05 +00:00
Paul Duffin
1935dce8eb Merge "Remove unused a.t.s.InstrumentationTestSuiteBuilder" 2017-06-21 07:46:03 +00:00
Paul Duffin
3724e7e5e9 Merge "Remove unused android.test.DatabaseTestUtils" 2017-06-21 07:46:00 +00:00
Paul Duffin
c66966d750 Merge "Remove unused a.t.InstrumentationCoreTestRunner" am: 1bfccadc81 am: dfc6939ed5
am: b3be07bc77

Change-Id: I12a6133de7ec7101327424854cf7a46debe3362d
2017-06-20 15:14:22 +00:00
Paul Duffin
b3be07bc77 Merge "Remove unused a.t.InstrumentationCoreTestRunner" am: 1bfccadc81
am: dfc6939ed5

Change-Id: I5ccdb58bbcde73a33bdce9b65d95aad2bf7b931f
2017-06-20 15:05:46 +00:00
Paul Duffin
e2e557976f Cleanup a.t.TestGrouping
TestGrouping is not part of the API but is used by classes that are and
so will need to be included in the static library we ship as part of the
SDK. As that library will be built directly from the source (as opposed
to android.jar which is built from stubs) developers will be able to see
classes and methods that are hidden and so not present in the stubs.

This change makes TestGrouping and its members as inaccessible as
possible. Unused methods and fields were removed and the TestGrouping
class was simplified by passing the ClassLoader into the constructor,
initializing the classLoader, making the classLoader field final,
and removing the setClassLoader(ClassLoader) method.

Bug: 30188076
Test: make checkbuild
Change-Id: Ie0545b1a61b74cdbc78667417f360b5197e2e128
2017-06-20 15:29:57 +01:00
Paul Duffin
44c717386d Remove unused a.t.InstrumentationUtils
Bug: 30188076
Test: make checkbuild
Change-Id: Ia06e4ae77f2c0ca341ef7c04f5f32bdd6a06d59c
2017-06-20 15:02:57 +01:00
Paul Duffin
575f9da647 Cleanup a.t.InstrumentationTestRunner
ARGUMENT_TEST_CLASS, ARGUMENT_TEST_PACKAGE, ARGUMENT_TEST_SIZE_PREDICATE
and ARGUMENT_DELAY_MSEC were made package private because they are not
part of the API and are only used from within the same package.

The JavaDoc comment was changed to a multi-line comment because it is
not and should not be associated with any member.

Fixed a couple of minor JavaDoc issues.

Bug: 30188076
Test: make checkbuild
Change-Id: If28460aec2fd0080e0f5346a83abae393b7a9fb2
2017-06-20 15:02:38 +01:00
Paul Duffin
4f1dbfed97 Remove unused a.t.s.InstrumentationTestSuiteBuilder
Bug: 30188076
Test: make checkbuild
Change-Id: I30514123c077e6047227f888f5f1a20e71ee1988
2017-06-20 15:01:36 +01:00
Paul Duffin
57d5b8d02d Remove unused a.t.InstrumentationCoreTestRunner
The only usage of this was in the unused
cts/tests/vm-tests-tf/AndroidManifest.xml which was deleted in
https://android-review.googlesource.com/#/c/418900/.

Bug: 30188076
Test: make checkbuild
Change-Id: I96f3586a7017f4cd14fa31207e0fff19c92f0de4
2017-06-20 14:58:33 +01:00
Paul Duffin
20fb642a5c Remove unused android.test.DatabaseTestUtils
Bug: 30188076
Test: make checkbuild
Change-Id: I11b1a3b90b9d17af9278ec8b28483eee01b75e81
2017-06-20 14:00:03 +01:00
Paul Duffin
5361c48199 Remove android.test dependencies on a.o.PerformanceCollector
The a.t.TimedTest annotation was removed because it was not in the API
and was only used by the code that has been removed.

The a.t.PerformanceCollectorTestCase was removed because it was not in
the API and its only purpose was to allow the AndroidTestRunner to
supply a PerformanceCollector.PerformanceResultsWriter to a test.

Bug: 62652137
Test: make checkbuild
Change-Id: Ie90a7004ade1448cb6bc7e029f6ba5620db29bfd
2017-06-20 10:26:29 +01:00
Paul Duffin
2fa69bdfce Merge "Added android.test.mock and android.test.mock.sdk targets" am: 46f8d427c4 am: de30ee2d40
am: e468747115

Change-Id: I50e3ae83eabe75cb87e0dd25acd05eee811c25ce
2017-06-06 08:13:12 +00:00
Paul Duffin
4823935a84 Added android.test.mock and android.test.mock.sdk targets
The android.test.mock will be used for any targets that require
android.test.mock classes but which do not already depend on the
sdk. It is also the library that will be added to the classpath
at runtime when an app has the following in their manifest.
    <uses-library android:name="android.test.mock"/>

The android.test.mock.sdk will be used by targets that require
android.test.mock classes and which build against the SDK. It
contains stub classes (like android.jar). It is also the library
that will be copied into the optional directory of the SDK.

(cherry picked from f74752293d1d25633aebc42c600717d0296a0820)

Bug: 30188076
Test: make checkbuild
Change-Id: If199180e1136da1927a9e7c7bcafbcfb29cf1274
Merged-In: Ia3fcd47c644b8e5a573f891571a7b3772eac63f9
2017-06-05 13:49:50 +01:00
Paul Duffin
f74752293d Added android.test.mock and android.test.mock.sdk targets
The android.test.mock will be used for any targets that require
android.test.mock classes but which do not already depend on the
sdk. It is also the library that will be added to the classpath
at runtime when an app has the following in their manifest.
    <uses-library android:name="android.test.mock"/>

The android.test.mock.sdk will be used by targets that require
android.test.mock classes and which build against the SDK. It
contains stub classes (like android.jar). It is also the library
that will be copied into the optional directory of the SDK.

Bug: 30188076
Test: make checkbuild
Change-Id: Ia3fcd47c644b8e5a573f891571a7b3772eac63f9
2017-06-05 11:19:58 +01:00
Christopher Tate
fe2368c38c Refresh in-memory SharedPreferences instances after restore
Existing instances don't know that the file has changed out from
under them, so they continue to return stale values from reads, and
risk overwriting restored data with stale content if writes are
performed.  We now tell the backing cache system to induce a
reload after restore (i.e. after we might have written a relevant
file out from under it).

Along the way we shook out an irregularity in the way we were
setting up the context topology of non-lifecycle instances of
the metadata-handling BackupAgent subclass, so that's fixed
now too.

Bug 12061817
Test: cts-tradefed run cts -m CtsBackupHostTestCases

Change-Id: I401fe9297235b55d8a8f041e430d122dc6e24129
2017-05-30 12:41:39 -07:00
Sunny Goyal
51829ae72f Merge "Setting Session commited broadcast when an existing apk is enabled for a different user" into oc-dev am: fc157e702f
am: 1e0a89055d

Change-Id: Ifefcd98f5df6a3175ad2d25aa058555ed02a4854
2017-05-12 21:27:37 +00:00
Sunny Goyal
1e0a89055d Merge "Setting Session commited broadcast when an existing apk is enabled for a different user" into oc-dev
am: fc157e702f

Change-Id: I4cabbad8bac8fb24c86506a89c29d0a34b90a564
2017-05-12 21:16:32 +00:00
Sunny Goyal
a31a74b993 Setting Session commited broadcast when an existing apk is enabled for
a different user

Test: Manual tests and CTS
Bug: 38204385
Change-Id: Ic3bddbc2e6070c11b11f0685077db7737f2b8849
2017-05-12 10:00:30 -07:00
Paul Duffin
e1124dee82 Merge changes I4c0e7fdd,I9ea3827a am: c876eece68 am: 557996e1d0 am: a158b3cb15
am: 943041abd2

Change-Id: Icc328d9243de8ff1e167313b5554a5bf757eab93
2017-05-12 13:10:58 +00:00
Paul Duffin
943041abd2 Merge changes I4c0e7fdd,I9ea3827a am: c876eece68 am: 557996e1d0
am: a158b3cb15

Change-Id: Ia76a1e34c541c64d4b226b9492ca6f05d30fc5a4
2017-05-12 13:03:29 +00:00