Merge changes Icd871654,I7c70328d am: 1efc2bc73f

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2418999

Change-Id: I9b83ff4a6c1d835b6ac61cfe1289deee5d1a4e42
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-02-13 16:51:03 +00:00 • committed by Automerger Merge Worker
commit b69c8bed56

View file

@ -2678,35 +2678,47 @@ public class TetheringTest {
public void testUpstreamNetworkChanged() {
final Tethering.TetherMainSM stateMachine = (Tethering.TetherMainSM)
mTetheringDependencies.mUpstreamNetworkMonitorSM;
final InOrder inOrder = inOrder(mNotificationUpdater);
// Gain upstream.
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
initTetheringUpstream(upstreamState);
stateMachine.chooseUpstreamType(true);
mTetheringEventCallback.expectUpstreamChanged(upstreamState.network);
verify(mNotificationUpdater)
inOrder.verify(mNotificationUpdater)
.onUpstreamCapabilitiesChanged(upstreamState.networkCapabilities);
// Set the upstream with the same network ID but different object.
final UpstreamNetworkState upstreamState2 = buildMobileIPv4UpstreamState();
initTetheringUpstream(upstreamState2);
stateMachine.chooseUpstreamType(true);
// Bug: duplicated upstream change event.
mTetheringEventCallback.expectUpstreamChanged(upstreamState2.network);
inOrder.verify(mNotificationUpdater)
.onUpstreamCapabilitiesChanged(upstreamState2.networkCapabilities);
// Lose upstream.
initTetheringUpstream(null);
stateMachine.chooseUpstreamType(true);
mTetheringEventCallback.expectUpstreamChanged(NULL_NETWORK);
verify(mNotificationUpdater).onUpstreamCapabilitiesChanged(null);
inOrder.verify(mNotificationUpdater).onUpstreamCapabilitiesChanged(null);
}
@Test
public void testUpstreamCapabilitiesChanged() {
final Tethering.TetherMainSM stateMachine = (Tethering.TetherMainSM)
mTetheringDependencies.mUpstreamNetworkMonitorSM;
final InOrder inOrder = inOrder(mNotificationUpdater);
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
initTetheringUpstream(upstreamState);
stateMachine.chooseUpstreamType(true);
inOrder.verify(mNotificationUpdater)
.onUpstreamCapabilitiesChanged(upstreamState.networkCapabilities);
stateMachine.handleUpstreamNetworkMonitorCallback(EVENT_ON_CAPABILITIES, upstreamState);
// Should have two onUpstreamCapabilitiesChanged().
// One is called by reportUpstreamChanged(). One is called by EVENT_ON_CAPABILITIES.
verify(mNotificationUpdater, times(2))
inOrder.verify(mNotificationUpdater)
.onUpstreamCapabilitiesChanged(upstreamState.networkCapabilities);
reset(mNotificationUpdater);
// Verify that onUpstreamCapabilitiesChanged won't be called if not current upstream network
// capabilities changed.
@ -2714,7 +2726,7 @@ public class TetheringTest {
upstreamState.linkProperties, upstreamState.networkCapabilities,
new Network(WIFI_NETID));
stateMachine.handleUpstreamNetworkMonitorCallback(EVENT_ON_CAPABILITIES, upstreamState2);
verify(mNotificationUpdater, never()).onUpstreamCapabilitiesChanged(any());
inOrder.verify(mNotificationUpdater, never()).onUpstreamCapabilitiesChanged(any());
}
@Test