summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/JavaClassGenerator_test.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2021-01-06 01:36:07 +0900
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-02-09 20:18:46 +0000
commit1d1ae5e7f44d1c9e370099023877c5b8807c1a31 (patch)
tree91e75dcd2df8418f58bfa1db5bf377e7c9b20c9c /tools/aapt2/java/JavaClassGenerator_test.cpp
parent3007352939aeb816f9447ec9d93433f6d27a969d (diff)
Improve testing of CONNECTIVITY_ACTION broadcasts.
We currently test CONNECTIVITY_ACTION broadcasts by directly registering BroadcastReceivers with BroadcastInterceptingContext, and making the receivers unregister themselves when all the broadcasts they expect have been received. This works for current test cases, but does not work if anything registers another receiver for CONNECTIVITY_ACTION. In that case, when we unregister the receiver in the receiver's onReceive method, BroadcastInterceptingContext will throw a ConcurrentModificationException because the list of receivers is being modified during iteration. Fix this by adding an ExpectedBroadcast class that stores the receiver and unregisters the receiver only when the test checks that the broadcast was received, which happens after the receiver runs. This is easier to use and also guarantees that the receiver is unregistered even if the test is expecting that the broadcast is never fired. Accordingly, remove mRegisteredReceivers and the code that uses it; it's no longer necessary now that ExpectedBroadcast always unregisters its receivers. Also add a convenience expectConnectivityAction method to expect a CONNECTIVITY_ACTION broadcast with specific contents. This makes the test easier to read and more detailed. Convert some existing tests to this method. While I'm at it, fix a test that was using "mCellNetworkAgent" to represent a wifi network. R backport notes: added import for NetworkInfo.DetailedState. That was added in aosp/1527378, which is impractical to backport. Bug: 172870110 Test: test-only change Change-Id: Ibada8b4215625e1016d9fd170526206920af76f5 Merged-In: Ibada8b4215625e1016d9fd170526206920af76f5 (cherry picked from commit d39cfb8de7ce7a789afd2c9e8ac3ca18fb8186ba)
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
0 files changed, 0 insertions, 0 deletions