53 Commits

Author SHA1 Message Date
Dario Freni
5f541cbb88 Add ability to stage multiple apexs.
Test: atest sharedlibs_hosts_test
Change-Id: I9dfc6b783fd63c555622932d59712c0e0b9b073e
2020-11-09 10:27:04 +00:00
Dario Freni
2d510d9b6c Avoid NullPointerException on non-existing file.
This change allows the method to throw a more informative exception
containing the file name that has not been found.

Test: used the library in sharedlibs_host_tests
Change-Id: I196385486ef4c121f1c655cd76c3ea5233e2a722
2020-11-05 14:32:18 +00:00
JW Wang
5b51c8c189 Rewrite how we abandon sessions
The original code is flawed in that `pm install-abandon` only abandons
the 1st session returned by `pm get-stagedsessions ...`.

1. move AbandonSessionsRule to be shared by multiple host tests
2. use AbandonSessionsRule to do the job

Bug: 160754072
Test: StagedInstallInternalTest
Change-Id: Ib7b32fbd7b1133ac6a8e6782234a4fe2c5a782bd
Merged-In: Ib7b32fbd7b1133ac6a8e6782234a4fe2c5a782bd
(cherry picked from commit 3ac333f2d20e240093235d957ba67ce174fe2db8)
2020-09-29 15:03:20 +01:00
Xin Li
628590d7ec Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Guang Zhu
6e634c03c6 address use of DummyIME in UI Automator
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: compile (code is not active in use)
Change-Id: Ice71490ff09969f229943d6ef952a09f4e283d14
Merged-In: Ice71490ff09969f229943d6ef952a09f4e283d14
2020-07-31 21:10:17 +00:00
Winson
db6d1df791 Fix PackageManagerServiceHostTests disk usage
It seems adb shell stop/start has a bug with taking up disk
space. For now, use a full reboot of the device for each
test step.

This will double the already extremely long test time, so the
entire PackageManagerServiceHostTests module has been moved
to postsubmit, except for tests annotated @Presubmit, of which
there are none as of this change.

Bug: 159540015
Bug: 159256824

Test: atest PackageManagerServiceHostTests

Change-Id: I67da61cb02baa572fc298e6f617d6e53ec2c4724
2020-06-25 10:19:51 -07:00
Winson
af8399a682 Fix original-package support
This broke in P. Basic support was broken by a simple negation
issue with the logic that checks for the original package.

That, along with the suggestion in the bug to fix the renamed
package association means this should now work as expected,
carrying data over from a previous installed, differently named
package.

Bug: 131355130
Bug: 132749720
Bug: 111967720

Test: atest PackageManagerServiceHostTests

Change-Id: Ifc4c7af47c4b633cd27ba4a40b6baa0e27960d71
2020-06-10 10:34:43 -07:00
Charles Chen
49f329ca66 Add WindowMetricsHelper
This metrics now is used for calculating the value reported by
Display#getSize. It could be extended to have more function later.

Also replace getCurrentMetrics usages to make them report
Display#getSize value.

Bug: 148904274
Test: atest WindowMetricsHelperTest

Change-Id: I182b6e63f7c28752eee22839cb9e69f073046c3f
2020-05-04 11:41:13 +08:00
Charles Chen
4bff5be1a9 Fix WindowContext leak
The root causes of this issue are:
  1. WindowTokenClient#attachContext makes WindowTokenClient has strong
     reference to WindowContext, which leads to WindowContext cannot be
     GC'd.
  2. WMS#removeWindowToken needs MANAGE_APP_TOKEN permission which
     normal apps don't hold.

This CL does following things:
  1. Use weak reference instead on WindowTokenClient#mContext.
  2. Relax WMS#removeWindowToken to check callingUid if
     MANAGE_WINDOW_TOKEN permission is not held
  3. Deliver config changes to the client side in
     WMS#addWindowTokenWithOption
  4. Some minor fixes

fixes: 150812449
Bug: 150715095
Test: atest WindowContextTest
Test: atest WindowManagerServiceTests
Test: atest WindowTokenTests
Test: atest WindowManagerPermissionTests#testMANAGE_APP_TOKENS
Test: atest
WindowManagerPermissionTests#testADD_WINDOW_TOKEN_WITH_OPTIONS

Change-Id: I9f1d73af2abb78fc9844e6d9eb25e9f0293514e7
2020-04-08 21:30:24 +08:00
Robert Horvath
e75cf0ac16 Deterministic PowerManagerServiceTest
To make PowerManagerServiceTest deterministic,
remove dependency on real time clock by mocking it out.
Use TestLooper, which allows making Handler behaviour deterministic as
well.

Test: atest PowerManagerServiceTest
Bug: 152193749
Change-Id: I4d9cd686ac672261bbb038249c0358e451b58710
2020-03-23 16:37:13 +01:00
Jorim Jaggi
57157ac5d8 Fix WindowInsetsController lifecycle
Provide a recording insets controller before the window gets
created, and replay the commands once a view gets attached. This
allows the client to use the controller in Activity.onCreate.

Test: WindowInsetsControllerTests
Bug: 118118435
Change-Id: I1a825ecc4367c02b27f2d08cd5442325315d4f89
2020-03-03 15:12:15 +01:00
Charles Chen
1ac295ec08 Revert "Revert "Always get window insets from server""
This reverts commit 288e1bd0455132643cf6e1dc482913f430e56bba.

The previous implementation of computeWindowInsets is to
use last view from WM#addView, which may be invalid because
the last added view is removed and throws NPE when getting
property from the invalid view.
In this CL, we change the approach to always obtain window
insets from server.

fixes: 148789183
fixes: 149480577
Test: atest FrameworksCoreTests:WindowMetricsTest
Test: atest WindowMetricsTests

Change-Id: I6db5970d14ac9eebe0ab0df65cb1300515ad1754
(cherry picked from commit 6bb2d4f68c02121850c62a83349aa35d36497afa)
2020-02-24 03:46:51 +00:00
Bill Lin
f351272c36 Add CutoutSpecificationTest in Presubmit Test scope
1) Add CutoutSpecificationTest in Presubmit
2) Add CutoutSpecificationTest in FrameworksTestsFilter

Fixes: 149883140
Test: atest FrameworksCoreTests:CutoutSpecificationTest
Test: adb shell am instrument -w \
    -e filter com.android.server.wm.test.filters.FrameworksTestsFilter \
    -e selectTest_verbose true \
    com.android.frameworks.coretests/androidx.test.runner.AndroidJUnitRunner

Change-Id: I7db8f7797740d48a158650b63b7e90e5f1f28361
2020-02-20 14:19:55 +08:00
Wale Ogunwale
288e1bd045 Revert "Always get window insets from server"
This reverts commit 3e857ec536f54fc08ab59bedcd878a819ebd71c3.

Reason for revert: Breaks wm-presubmit

Change-Id: I03fbbb01c8cabd0ebb9193adf640b9f07ce19826
2020-02-14 13:54:34 +00:00
Charles Chen
3e857ec536 Always get window insets from server
The previous implementation of computeWindowInsets is to
use last view from WM#addView, which may be invalid because
the last added view is removed and throws NPE when getting
property from the invalid view.
In this CL, we change the approach to always obtain window
insets from server.

fixes: 148789183
Test: atest FrameworksCoreTests:WindowMetricsTest
Test: atest WindowMetricsTests

Change-Id: Ic5512c31f86c597d99e13d29df654d3f527d6b55
2020-02-12 11:09:25 +08:00
Hongming Jin
bc76112e0b System action registration API for SystemUI
Bug: 136286274
Test: atest AccessibilityManagerTest
      atest AccessibilityManagerServiceTest
Change-Id: I6bbdf3627bfc9b39551cc7809dda1cf43d1d6ea4
2020-01-08 11:22:48 -08:00
Ram Muthiah
637138dd94 Revert "Overlay, actor, and target app visibility handling"
This reverts commit 3f46dbd7a091b5e594be6055ab11d0e0cfe25a18.

Bug: 146018363
Test: Treehugger
2019-12-11 17:37:37 -08:00
Ram Muthiah
a4bb0444d9 Revert "Fix WmTests presubmit failure"
This reverts commit f0385c5ad344eb730cf36046771b84fbac94b51d.

Bug: 146018363
Test: Treehugger
2019-12-11 17:37:00 -08:00
Louis Chang
f0385c5ad3 Fix WmTests presubmit failure
Adding another library that excludes mockito for WmTests to avoid
conflicting with extended-mockito.

Test: presubmit pass
Change-Id: If3f6d7a2ac52d3e8f72e9cbc88e54f0c4d4c47ce
2019-12-10 18:33:57 +08:00
Winson
3f46dbd7a0 Overlay, actor, and target app visibility handling
Hooks AppsFilter to support exposing a target and any overlays
targeting it to the actor specified in its overlayable block.

Sacrifices some install-time performance in favor of less memory
usage and easier to follow code by doing a full search/rebuild
on each change.

Benchmarks TBD

Bug: 143096091

Test: atest OverlayReferenceMapperTests

Change-Id: Ic832818b9aa383f1167ca3e69a11b8459fa9db97
2019-12-09 10:46:59 -08:00
Jorim Jaggi
956ca413e3 Window Manager Flag Migration (4/n)
Wire up the appearance and the transient state of system bars between
WMS and System UI. The derived classes of CommandQueue.Callbacks no
longer listen to setSystemUiVisibility, but listen to showTransient,
abortTransient, and onSystemBarAppearanceChanged instead.

Bug: 118118435
Test: atest InsetsSourceProviderTest InsetsStateControllerTest
            InsetsPolicyTest WindowStateTests CommandQueueTest
            RegisterStatusBarResultTest InsetsFlagsTest
            LightBarControllerTest
Test: build on specific target
Change-Id: Ie35f4b4468bce7ef8c76f091e306610c069fba85
2019-10-19 16:59:06 +08:00
Ioannis Ilkos
8cca14103c Revert "Window Manager Flag Migration (4/n)"
This reverts commit cb1b848084be47118342c4893ede2298067c3d0f.

Reason for revert: Droidcop-triggered revert due to b/142849532

Change-Id: If81eba4e979e21202e78839bb1afbc66691098d2
2019-10-17 09:38:00 +00:00
Jorim Jaggi
cb1b848084 Window Manager Flag Migration (4/n)
Wire up the appearance and the transient state of system bars between
WMS and System UI. The derived classes of CommandQueue.Callbacks no
longer listen to setSystemUiVisibility, but listen to showTransient,
abortTransient, and onSystemBarAppearanceChanged instead.

Bug: 118118435
Test: atest InsetsSourceProviderTest InsetsStateControllerTest
            InsetsPolicyTest WindowStateTests CommandQueueTest
            RegisterStatusBarResultTest InsetsFlagsTest
            LightBarControllerTest
Change-Id: I1dcaff47ae57ccee91146fdc042cde5e26fc0b3f
2019-10-17 01:41:34 +08:00
Roshan Pius
f145e1732e TestLooper: Some changes to test looper behavior
a) Add a new stopAutoDispatchAndIgnoreExceptions method
This method ignores exceptions raised when there are no messages
dispatched in the looper. Helps write negative unit tests for methods where
the runnables are not posted when some preconditions are not met.
Not starting the looper in these tests would make it
unclear whether the test failed because the looper was not running or
because the preconditions (like permission checks) where not satisfied.
b) Auto dispatch will only stop running when stopAutoDispatch is
invoked. Previously it stops running when it runs a single message. This
causes failures in unit tests for methods which posts multiple runnables
in the same method.

Bug: 138403307
Bug: 117601161
Test: atest com.android.server.wifi
Change-Id: Iab27d92d443c6d7364c52b86d51dd2cb7902358a
2019-09-19 20:41:32 -07:00
Jorim Jaggi
2862047fd7 Window Manager Flag Migration (2/n)
Adds policy to decide when focused window can control bars. And also
generalizes control target for:
a) Normal case: The focused window is the control target.
b) Transient bar case: The control target is a special object in WM
   that controls the transient animation.

Bug: 118118435
Test: atest InsetsPolicyTest InsetsStateControllerTest WindowStateTests
Change-Id: I4819d85eec745d56abe23dbca0905979da854e5e
2019-09-05 18:20:06 +08:00
Andrii Kulian
153f73cbcc Merge "Add unit tests for activity client state changes" into qt-dev 2019-04-16 21:18:18 +00:00
Andrii Kulian
ca7f710eee Add unit tests for activity client state changes
This also adds new module for tests that require Extended Mockito.

Bug: 127106719
Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest
Change-Id: I7ed5de72d35babbbf72c4c823d3a9e4baa50e3c4
2019-04-05 16:07:59 -07:00
Roshan Pius
e602db5fb9 WifiScannerTest: More unit tests
Bug: 130035791
Test: ./frameworks/base/wifi/tests/runtests.sh
Change-Id: Ic4eb56fc3ba6bffd3df529432d17af0ba35b6333
2019-04-05 15:16:56 -07:00
Tadashi G. Takaoka
82eb7a5f63 Rename WM test filter to FrameworksTestsFilter
This CL adds android.view.InsetsAnimationControllerImplTest to the
test filter, and adds a comment to each tests mentioning about
FrameworksTestsFilter.

Test: Pass all 91 non-flaky presubmit tests in FrameworksCoreTests
      using FrameworksTestsFilter
  $ tradefed.sh run commandAndExit FrameworksCoreTests \
      --instrumentation-arg selectTest=com.android.server.wm. \
      --instrumentation-arg filter=com.android.server.wm.test.filters.FrameworksTestsFilter
      --include-annotation android.platform.test.annotations.Presubmit \
      --exclude-annotation androidx.test.filters.FlakyTest
Bug: 122451194

Change-Id: I9592ff01158eec1b4ef4d0dd22be243e10bd198e
2019-03-26 22:15:22 +09:00
Tadashi G. Takaoka
9648d4b04b Make SelectTest append selectTest argument from extended class
This CL also moves CoreTestsFilter to frameworks/base/test-util, so
that FrameworksCoreTests, FrameworksServicesTests, and WmTests can use
CoreTestsFilter.

Test: Pass SelectTestTests
  $ atest WmTests:com.android.test.filters.SelectTestTests
Test: Pass all 91 non-flaky presubmit tests in FrameworksCoreTests using
  CoreTestsFilter
  $ tradefed.sh run commandAndExit WmTests \
      --instrumentation-arg selectTest=com.android.server.wm. \
      --instrumentation-arg filter=com.android.server.wm.test.filters.CoreTestsFilter
      --include-annotation android.platform.test.annotations.Presubmit \
      --exclude-annotation androidx.test.filters.FlakyTest
Test: Pass all 740 non-flaky presubmit tests in WmTests using
  CoreTestsFilter
  $ tradefed.sh run commandAndExit WmTests \
      --instrumentation-arg selectTest=com.android.server.wm. \
      --instrumentation-arg filter=com.android.server.wm.test.filters.CoreTestsFilter
      --include-annotation android.platform.test.annotations.Presubmit \
      --exclude-annotation androidx.test.filters.FlakyTest
Bug: 122451194
Change-Id: I83d13d9ef82a92677bee67da5ee8a5faa0690f82
2019-03-22 18:04:30 +09:00
Sasha Smundak
ba36f89d7f Merge "Convert tests/**/Android.mk files to Android.bp" am: 40ff4f7d83 am: c33506ce2f
am: c15ff15587

Change-Id: I55c5f273e09a2a0ad53fdd8cb4860f04207c4241
2019-03-09 08:25:50 -08:00
Sasha Smundak
b6aca11e80 Convert tests/**/Android.mk files to Android.bp
See build/soong/README.md for more information.

Note: tests/ImfTest/Android.mk causes conflict as it hasn't been yet
ported to internal master. Do it later.
Note: the conversion in the following directories has to be done in the
internal master first because of the conflicts:
* tests/ActivityManagerPerfTests
* tests/AppLaunch
* tests/AppLaunchWear
* tests/BackgroundDexOptServiceIntegrationTests
* tests/Camera2Tests/CameraToo
* tests/Camera2Tests/SmartCamera/SimpleCamera
* tests/Compatibility
* tests/Internal
* tests/RcsTests
* tests/ServiceCrashTest
* tests/UsbTests

Bug: 122332340
Test: treehugger
Change-Id: Ie17590c6a96aee5caa80d38092a3de5c1b6efe8d
2019-03-07 16:14:00 -08:00
Sasha Smundak
aef4b82881 Remove unused tests/utils/SleepUtils
The presense of these files hinders the conversion of the makefiles
to the blueprints (causes failure in the internal builds due to lacking
files).

Bug: 122332340
Test: treehugger
Change-Id: I2a3c38cbba7c14ae1b2880c73c7f6514816f0e68
2019-02-26 17:43:22 +00:00
Tarandeep Singh
a6f3561667 Reparent IME window and handle non-fullscreen windows correctly
IME window is attached to the IME target if possible. This ensures
a smooth enter/exit animation when the activity is coming in/going
away.

Furthermore, if the controlling window doesn't span the entire
display, we can't offer controlling it in a frame-by-frame
manner, and we need to do the inset calculations relative to the
display frame.

Test:
adb shell setprop persist.wm.new_insets 1
adb shell setprop persist.pre_render_ime_views 0

Test: Open IME, go home, reopen app
Test: Show dialog with EditText
Bug: 111084606
Change-Id: Id40470f6f8284b48acfa4719049afd14fde332d6
2019-02-07 15:56:21 +01:00
Tadashi G. Takaoka
0f224efb5e Add generic SelectTest JUnit filter and CoreTestsFilter
The JUnit filter com.android.test.filters.SelectTest is a generic test
filter that can supersede |-e package| and |-e class| options of
AndroidJUnitRunner.

The com.android.server.wm.test.filters.CoreTestsFilter extends SelectTest
filter to filter out Window Manager Service releated tests in
FrameworksCoreTests.

Bug: 122451194
Test: Can select some tests from WmTests.
  $ adb shell am instrument -w \
      -e filter com.android.test.filters.SelectTest \
      -e selectTest com.android.test.filters.,com.android.server.wm.DummyTests \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: CoreTestsFilter works for FrameworksCoreTests.
  $ adb shell am instrument -w \
      -e filter com.android.server.wm.test.filters.CoreTestsFilter \
      -e selectTest_verbose true \
      com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ic72637997bf17debef914e2596049f6cf3e753de
Merged-In: Ic72637997bf17debef914e2596049f6cf3e753de
2019-01-23 23:04:03 +09:00
Tadashi G. Takaoka
4ca00224e9 Fix some tests in SelectTestTests
This is a follow up of Ic72637997bf17debef914e2596049f6cf3e753de

Bug: 122451194
Test: atest FrameworksServicesTests:com.android.test.filters.SelectTestTests
Change-Id: I61c5837a097451a204e9602476c68fdda4fc30be
2019-01-23 22:16:05 +09:00
TreeHugger Robot
9e6a6185b6 Merge "Add generic SelectTest JUnit filter and CoreTestsFilter" 2019-01-23 08:17:31 +00:00
Tadashi G. Takaoka
2bc664065e Add generic SelectTest JUnit filter and CoreTestsFilter
The JUnit filter com.android.test.filters.SelectTest is a generic test
filter that can supersede |-e package| and |-e class| options of
AndroidJUnitRunner.

The com.android.server.wm.test.filters.CoreTestsFilter extends SelectTest
filter to filter out Window Manager Service releated tests in
FrameworksCoreTests.

Bug: 122451194
Test: Can select some tests from WmTests.
  $ adb shell am instrument -w \
      -e filter com.android.test.filters.SelectTest \
      -e selectTest com.android.test.filters.,com.android.server.wm.DockedStackDividerControllerTests \
      com.android.frameworks.wmtests/androidx.test.runner.AndroidJUnitRunner
Test: CoreTestsFilter works for FrameworksCoreTests.
  $ adb shell am instrument -w \
      -e filter com.android.server.wm.test.filters.CoreTestsFilter \
      -e selectTest_verbose true \
      com.android.frameworks.coretests/androidx.test.runner.AndroidJUnitRunner

Change-Id: Ic72637997bf17debef914e2596049f6cf3e753de
2019-01-23 10:36:44 +09:00
Aurimas Liutikas
42249cb7c2 Remove unused SleepUtils.
This looks like dead code not used by anything in the tree.
It was added in ag/603441

Test: None
Change-Id: Ic424a25794d7c45719fa4f554cbf4f4b74288065
2019-01-22 13:48:47 -08:00
Brett Chabot
ec6bcbceee Fix FrameworksServicesTests:StorageManagerServiceTest
Use androidx.test not android.support.test.
And remove android.support.test from build by removing unnecessary
frameworks-base-testutils > android.support.test dependency

Bug: 117990406
Test: m checkbuild; atest FrameworksServicesTests:StorageManagerServiceTest
Change-Id: Ia825e0926b46855f9056739441cb21a065692076
2018-11-06 10:48:19 -08:00
Colin Cross
74835a2a4f Convert frameworks-base-testutils to Android.bp
See build/soong/README.md for more information.

Test: m checkbuild
Change-Id: I2d70f7c017fc3d181c70b030e39e5a932d0996cc
2018-08-16 22:25:40 -07:00
Tyler Gunn
f955e56d51 Require READ_CALL_LOG permission to see phone numbers in phone state.
Incoming and outgoing call phone numbers are visible in the phone state
broadcast and via the PhoneStateListener.  To enhance user privacy, change
to require the READ_CALL_LOG permission in order to receive the call
phone numbers.

This means to see phone numbers:
1. android.intent.action.PHONE_STATE - requires READ_PHONE_STATE and
READ_CALL_LOG permission.
2. PhoneStateListener#onCallStateChanged - now required READ_CALL_LOG
permission.

To support this new behavior, added sendBroadcastAsUserMultiplePermissions
method to context to allow sending the broadcast to all users while
requiring the two permissions.

Bug: 78650469
Test: Created PHONE_STATE broadcast receiver in test app and verified that
when no permissions are granted, the phone number is empty for incoming
and outgoing calls.
Test: Granted Phone state permission to test app and verified that phone
number is not populated.
Test: Granted test app read call log permission and verified that phone
number is populated.
Test: Created PhoneStateListener in test app and verified that when no
permissions are granted, phone number is empty for incoming and outgoing.
calls.
Test: Granted read call log permission to test app and verified that both
the incoming and outgoing numbers are populated.

Change-Id: I857ea00cc58a0abbb77960643f361dd6dd9c8b56
2018-04-27 08:44:07 -07:00
Anton Hansson
ab6ec61251 frameworks/base: Set LOCAL_SDK_VERSION where possible.
This change sets LOCAL_SDK_VERSION for all packages where
this is possible without breaking the build, and
LOCAL_PRIVATE_PLATFORM_APIS := true otherwise.

Setting one of these two will be made required soon, and this
is a change in preparation for that. Not setting LOCAL_SDK_VERSION
makes the app implicitly depend on the bootclasspath, which is
often not required. This change effectively makes depending on
private apis opt-in rather than opt-out.

Test: make relevant packages
Bug: 73535841
Change-Id: I4233b9091d9066c4fa69f3d24aaf367ea500f760
2018-02-28 15:13:23 +00:00
Etan Cohen
cff2fe4f76 Add Executor to the TestLooper
Add a method to obtain an Executor from a TestLooper: the executor
executes on a new Handler on the test looper.

Bug: 73088768
Test: new unit test for executor
Change-Id: Ib0aa10011116a4d998f8d3a7434939338d9b516d
2018-02-16 10:13:26 -08:00
Philip P. Moltmann
9addc597e3 Don't include mockito in frameworks-base-testutils
So that each test can pick if they want mockito-inline or not.

Test: m -j checkbuild
Change-Id: I1ac02acebbe5cd01f3032a10932a1c612d8d3a4d
2017-12-19 13:22:14 -08:00
Paul Duffin
2710ca1e9d Flatten dependency hierarchy of legacy-android-test
Previous changes statically included legacy-android-test in preparation
for removing android.test.* and junit.* classes from the android.jar.
Unfortunately, that lead to duplicate classes between APKs and the
bootclasspath which caused build problems (Proguard) and also runtime
problems (when targeting and running on older releases).

Switching from statically including the classes to using the runtime
libraries cannot be done in one step because legacy-android-test is
statically included in libraries which are used in many APKs and so
removing it from those libraries requires that all APKs be updated at
once. Doing that atomically across dozens of projects is not practical.

This change modifies APKS that statically include the
legacy-android-test library indirectly.

* If the APK manifest uses the android.test.runner library then the APK
  is modified to stop statically including legacy-android-test and
  instead build against android.test.base/mock/runner libraries instead.

* Otherwise, the APK statically includes legacy-android-test.

Also, any libraries that statically include are modified to stop
statically including it and if it has source dependencies on the classes
is changed to build against the android.test.base/mock/runner libraries.

The following change descriptions were generated automatically and so
may be a little repetitive. They are provided to give the reviewer
enough information to check the comments match what has actually been
changed and check the reasoning behind the changes.

* cmds/uiautomator/instrumentation/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because uiautomator-instrumentation is not a package so does not
    need to statically include the classes

* cmds/uiautomator/library/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    uiautomator.core has a source dependency on its classes

    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because uiautomator.core is not a package so does not need to
    statically include the classes

* core/tests/BroadcastRadioTests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    BroadcastRadioTests's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    BroadcastRadioTests specifies in its manifest.

* core/tests/coretests/Android.mk
    Added 'android.test.base' and 'android.test.mock' to
    LOCAL_JAVA_LIBRARIES because FrameworksCoreTests's source depends
    on their classes and because of these changes they are no longer
    present on the compilation path. The classes do not need to be
    statically included because the classes will be provided by the
    runtime, either from the default bootclasspath or from the
    android.test.runner library that FrameworksCoreTests specifies in
    its manifest.

* core/tests/featureflagtests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksCoreFeatureFlagTests's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that FrameworksCoreFeatureFlagTests specifies in its manifest.

* core/tests/systemproperties/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksCoreSystemPropertiesTests's source depends on its classes
    and because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that FrameworksCoreSystemPropertiesTests specifies in its manifest.

* core/tests/utillib/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because frameworks-core-util-lib is not a package so does not need
    to statically include the classes

    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    frameworks-core-util-lib has a source dependency on its classes

* core/tests/utiltests/Android.mk
    Added 'android.test.base' and 'android.test.mock' to
    LOCAL_JAVA_LIBRARIES because FrameworksUtilTests's source depends
    on their classes and because of these changes they are no longer
    present on the compilation path. The classes do not need to be
    statically included because the classes will be provided by the
    runtime, either from the default bootclasspath or from the
    android.test.runner library that FrameworksUtilTests specifies in
    its manifest.

* location/tests/locationtests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksLocationTests's source depends on its classes and because
    of these changes they are no longer present on the compilation
    path. The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    FrameworksLocationTests specifies in its manifest.

* lowpan/tests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksLowpanApiTests's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that FrameworksLowpanApiTests specifies in its manifest.

* packages/Osu2/tests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    OsuTests's source depends on its classes and because of these
    changes they are no longer present on the compilation path. The
    classes do not need to be statically included because the classes
    will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that OsuTests
    specifies in its manifest.

* packages/SettingsProvider/test/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' in
    LOCAL_JAVA_LIBRARIES because SettingsProviderTest's source depends
    on its classes. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that SettingsProviderTest specifies in its manifest.

* services/tests/notification/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksNotificationTests's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that FrameworksNotificationTests specifies in its manifest.

* services/tests/servicestests/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' and
    'android.test.runner' in LOCAL_JAVA_LIBRARIES because
    FrameworksServicesTests's source depends on their classes. The
    classes do not need to be statically included because the classes
    will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    FrameworksServicesTests specifies in its manifest.

* services/tests/shortcutmanagerutils/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    ShortcutManagerTestUtils has a source dependency on its classes

* tests/AppLaunch/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' and
    'android.test.runner' in LOCAL_JAVA_LIBRARIES because AppLaunch's
    source depends on their classes. The classes do not need to be
    statically included because the classes will be provided by the
    runtime, either from the default bootclasspath or from the
    android.test.runner library that AppLaunch specifies in its
    manifest.

* tests/Camera2Tests/SmartCamera/SimpleCamera/tests/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' in
    LOCAL_JAVA_LIBRARIES because SmartCamera-tests's source depends on
    its classes. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that SmartCamera-tests specifies in its manifest.

* tests/ServiceCrashTest/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' in
    LOCAL_JAVA_LIBRARIES because ServiceCrashTest's source depends on
    its classes. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that ServiceCrashTest specifies in its manifest.

* tests/net/Android.mk
    Added 'android.test.base' and 'android.test.mock' to
    LOCAL_JAVA_LIBRARIES because FrameworksNetTests's source depends on
    their classes and because of these changes they are no longer
    present on the compilation path. The classes do not need to be
    statically included because the classes will be provided by the
    runtime, either from the default bootclasspath or from the
    android.test.runner library that FrameworksNetTests specifies in
    its manifest.

* tests/testables/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because testables is not a package so does not need to statically
    include the classes

    Added 'android.test.mock' to LOCAL_JAVA_LIBRARIES because testables
    has a source dependency on its classes

* tests/utils/testutils/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because frameworks-base-testutils is not a package so does not need
    to statically include the classes

    Added 'android.test.base' and 'android.test.mock' to
    LOCAL_JAVA_LIBRARIES because frameworks-base-testutils has a source
    dependency on their classes

* wifi/tests/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    FrameworksWifiApiTests's source depends on its classes and because
    of these changes they are no longer present on the compilation
    path. The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    FrameworksWifiApiTests specifies in its manifest.

Bug: 30188076
Test: make checkbuild
Change-Id: Ia6a48234f28e7e1789049cf4b37cd7fe0bc8251c
2017-12-07 07:38:59 +00:00
Sudheer Shanka
aa3c30dfa2 Add a way to clear cached provider for tests in Settings class.
Bug: 38437704
Bug: 38433611
Test: manual
Change-Id: Id2803359644bd68a158294b6d801fc9cd316fc9f
2017-05-26 18:53:06 +00:00
Paul Duffin
8aeb59ebcd Prepare for removal of legacy-test from default targets
In preparation for removing junit classes from the Android API
the legacy-test target will be removed from the
TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit
dependencies on junit and/or legacy-android-test to ensure that
modules will compile properly once it is removed.

Bug: 30188076
Test: make checkbuild
Change-Id: I13e88297731253420e4e5f5291d503f13a39a156
2017-01-18 16:39:34 +00:00
Lorenzo Colitti
281a17c958 De-guava BroadcastInterceptingContext and move it to testutils.
Removing the static dependency on guava reduces test compile time
by about 20 seconds on a Z840, thus substantially speeding up the
compile/test cycle.

Make FutureIntent public instead of package-private because it is
used directly by NetworkPolicyManagementServiceTest, which as of
this CL is now in a different package.

Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.NetworkPolicyManagerServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.net.NetworkStatsServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.NetworkManagementServiceTest  # Already failing.
Bug: 31479480
Change-Id: Ifab32c9214e9caab71dbf93b3d3ca88df6f49636
2016-10-28 17:12:36 +09:00
Lorenzo Colitti
7df1a82802 Move FakeSettingsProvider to a common location.
Test: runtest frameworks-util -c com.android.internal.util.test.FakeSettingsProviderTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-services -c com.android.server.retaildemo.PreloadAppsInstallerTest
Test: runtest frameworks-services -c com.android.server.retaildemo.RetailDemoModeServiceTest
Bug: 31479480
Change-Id: I82a1a1a7219cf1385092b84d85eddf9dda90c685
2016-10-28 17:12:31 +09:00