From 8c32adf149673d72184ddcab636d7dd8af35c565 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Thu, 22 Apr 2021 17:45:15 +0900 Subject: [PATCH] Adjust a test for policy scoring Bug: 184834350 Test: this Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f Merged-In: Ib161503c0e6f73c5b5017ae554bbdc28ac3edb3e Change-Id: Ib161503c0e6f73c5b5017ae554bbdc28ac3edb3e (cherry-picked from ag/14272003) --- .../src/android/net/cts/NetworkAgentTest.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt index b3ac3f63bc..1a75a7fa79 100644 --- a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt +++ b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt @@ -546,16 +546,23 @@ class NetworkAgentTest { // Connect the first Network createConnectedNetworkAgent(name = name1).let { (agent1, _) -> callback.expectAvailableThenValidatedCallbacks(agent1.network) - // Upgrade agent1 to a better score so that there is no ambiguity when - // agent2 connects that agent1 is still better - agent1.sendNetworkScore(BETTER_NETWORK_SCORE - 1) + // If using the int ranking, agent1 must be upgraded to a better score so that there is + // no ambiguity when agent2 connects that agent1 is still better. If using policy + // ranking, this is not necessary. + agent1.sendNetworkScore(NetworkScore.Builder().setLegacyInt(BETTER_NETWORK_SCORE) + .build()) // Connect the second agent createConnectedNetworkAgent(name = name2).let { (agent2, _) -> agent2.markConnected() - // The callback should not see anything yet + // The callback should not see anything yet. With int ranking, agent1 was upgraded + // to a stronger score beforehand. With policy ranking, agent1 is preferred by + // virtue of already satisfying the request. callback.assertNoCallback(NO_CALLBACK_TIMEOUT) - // Now update the score and expect the callback now prefers agent2 - agent2.sendNetworkScore(BETTER_NETWORK_SCORE) + // Now downgrade the score and expect the callback now prefers agent2 + agent1.sendNetworkScore(NetworkScore.Builder() + .setLegacyInt(WORSE_NETWORK_SCORE) + .setExiting(true) + .build()) callback.expectCallback(agent2.network) } }