1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.wifi;
18 
19 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_AUTHENTICATION;
20 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_BUSY;
21 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK;
22 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_CONFIGURATION;
23 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION;
24 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_ENROLLEE_FAILED_TO_SCAN_NETWORK_CHANNEL;
25 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION;
26 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC;
27 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_INVALID_NETWORK;
28 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_INVALID_URI;
29 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_NOT_COMPATIBLE;
30 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_NOT_SUPPORTED;
31 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_TIMEOUT;
32 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_URI_GENERATION;
33 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_APPLIED;
34 import static android.net.wifi.EasyConnectStatusCallback.EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_SENT;
35 
36 import static com.android.server.wifi.DppMetrics.DPP_OPERATION_TIME;
37 
38 import static org.junit.Assert.assertEquals;
39 import static org.junit.Assert.assertTrue;
40 import static org.junit.Assume.assumeTrue;
41 
42 import androidx.test.filters.SmallTest;
43 
44 import com.android.modules.utils.build.SdkLevel;
45 import com.android.server.wifi.proto.nano.WifiMetricsProto;
46 import com.android.server.wifi.proto.nano.WifiMetricsProto.HistogramBucketInt32;
47 
48 import org.junit.After;
49 import org.junit.Before;
50 import org.junit.Test;
51 
52 import java.util.Random;
53 
54 /**
55  * Unit tests for {@link com.android.server.wifi.DppMetrics}.
56  */
57 @SmallTest
58 public class DppMetricsTest extends WifiBaseTest {
59     private static final int MAX_ITERATIONS = 30;
60 
61     private DppMetrics mDppMetrics = new DppMetrics();
62 
63     @Before
setUp()64     public void setUp() throws Exception {
65         mDppMetrics.clear();
66     }
67 
68     @After
cleanUp()69     public void cleanUp() {
70         mDppMetrics.clear();
71     }
72 
73     /**
74      * Helper function that matches histogram buckets to an expected value
75      *
76      * @param index Bucket index
77      * @param value Expected value
78      */
checkOperationBucketEqualsTo(int index, int value)79     private void checkOperationBucketEqualsTo(int index, int value) {
80         // Confirm that the consolidated log has the expected value
81         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
82         HistogramBucketInt32 hb = mWifiDppLogProto.dppOperationTime[index];
83         assertEquals(hb.count, value);
84     }
85 
86     /**
87      * Helper function that returns a number to be used to call a counter update method
88      *
89      * @param max Upper limit for the random number
90      * @return returns a random number between 0 and max
91      */
getNumOfTimes(int max)92     private int getNumOfTimes(int max) {
93         Random random = new Random();
94         return random.nextInt(max);
95     }
96 
97     /**
98      * Helper function to check DPP Failures in the histogram bucket
99      *
100      * @param key   Key to verify
101      * @param value Expected value
102      */
checkDppFailures(int key, int value)103     private void checkDppFailures(int key, int value) {
104         boolean found = false;
105 
106         // Confirm that the consolidated log has the expected value
107         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
108 
109         for (WifiMetricsProto.WifiDppLog.DppFailureStatusHistogramBucket hb :
110                 mWifiDppLogProto.dppFailureCode) {
111             if (hb.dppStatusType == key) {
112                 assertEquals(hb.count, value);
113                 found = true;
114                 break;
115             }
116         }
117 
118         assertTrue(found);
119     }
120 
121     /**
122      * Helper function to check DPP Successes in the histogram bucket
123      *
124      * @param key   Key to verify
125      * @param value Expected value
126      */
checkDppSuccesses(int key, int value)127     private void checkDppSuccesses(int key, int value) {
128         boolean found = false;
129 
130         // Confirm that the consolidated log has the expected value
131         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
132 
133         for (WifiMetricsProto.WifiDppLog.DppConfiguratorSuccessStatusHistogramBucket hb :
134                 mWifiDppLogProto.dppConfiguratorSuccessCode) {
135             if (hb.dppStatusType == key) {
136                 assertEquals(hb.count, value);
137                 found = true;
138                 break;
139             }
140         }
141 
142         assertTrue(found);
143     }
144 
145     /**
146      * Test numDppConfiguratorInitiatorRequests
147      *
148      * @throws Exception
149      */
150     @Test
testUpdateDppConfiguratorInitiatorRequests()151     public void testUpdateDppConfiguratorInitiatorRequests() throws Exception {
152         // Get a random value and call the update method 'value' times
153         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
154 
155         for (int i = 0; i < value; i++) {
156             mDppMetrics.updateDppConfiguratorInitiatorRequests();
157         }
158 
159         // Confirm that the consolidated log has the expected value
160         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
161         assertEquals(mWifiDppLogProto.numDppConfiguratorInitiatorRequests, value);
162     }
163 
164     /**
165      * Test numDppEnrolleeInitiatorRequests
166      *
167      * @throws Exception
168      */
169     @Test
testUpdateDppEnrolleeInitiatorRequests()170     public void testUpdateDppEnrolleeInitiatorRequests() throws Exception {
171         // Get a random value and call the update method 'value' times
172         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
173 
174         for (int i = 0; i < value; i++) {
175             mDppMetrics.updateDppEnrolleeInitiatorRequests();
176         }
177 
178         // Confirm that the consolidated log has the expected value
179         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
180         assertEquals(mWifiDppLogProto.numDppEnrolleeInitiatorRequests, value);
181     }
182 
183     /**
184      * Test numDppEnrolleeResponderRequests
185      *
186      * @throws Exception
187      */
188     @Test
testUpdateDppEnrolleeResponderRequests()189     public void testUpdateDppEnrolleeResponderRequests() throws Exception {
190         assumeTrue(SdkLevel.isAtLeastS());
191         // Get a random value and call the update method 'value' times
192         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
193 
194         for (int i = 0; i < value; i++) {
195             mDppMetrics.updateDppEnrolleeResponderRequests();
196         }
197 
198         // Confirm that the consolidated log has the expected value
199         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
200         assertEquals(mWifiDppLogProto.numDppEnrolleeResponderRequests, value);
201     }
202 
203     /**
204      * Test EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_SENT
205      *
206      * @throws Exception
207      */
208     @Test
testUpdateDppConfiguratorSuccess()209     public void testUpdateDppConfiguratorSuccess() throws Exception {
210         // Get a random value and call the update method 'value' times
211         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
212 
213         for (int i = 0; i < value; i++) {
214             mDppMetrics.updateDppConfiguratorSuccess(EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_SENT);
215         }
216         for (int i = 0; i < value; i++) {
217             mDppMetrics.updateDppConfiguratorSuccess(
218                     EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_APPLIED);
219         }
220 
221         // Confirm that the consolidated log has the expected value
222         checkDppSuccesses(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_SENT,
223                 value);
224         checkDppSuccesses(WifiMetricsProto.WifiDppLog
225                 .EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_APPLIED, value);
226     }
227 
228     /**
229      * Test numDppEnrolleeSuccess
230      *
231      * @throws Exception
232      */
233     @Test
testUpdateDppEnrolleeSuccess()234     public void testUpdateDppEnrolleeSuccess() throws Exception {
235         assumeTrue(SdkLevel.isAtLeastS());
236         // Get a random value and call the update method 'value' times
237         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
238 
239         for (int i = 0; i < value; i++) {
240             mDppMetrics.updateDppEnrolleeSuccess();
241         }
242 
243         // Confirm that the consolidated log has the expected value
244         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
245         assertEquals(mWifiDppLogProto.numDppEnrolleeSuccess, value);
246     }
247 
248     /**
249      * Test numDppEnrolleeResponderSuccess
250      *
251      * @throws Exception
252      */
253     @Test
testUpdateDppEnrolleeResponderSuccess()254     public void testUpdateDppEnrolleeResponderSuccess() throws Exception {
255         // Get a random value and call the update method 'value' times
256         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
257 
258         for (int i = 0; i < value; i++) {
259             mDppMetrics.updateDppEnrolleeResponderSuccess();
260         }
261 
262         // Confirm that the consolidated log has the expected value
263         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
264         assertEquals(mWifiDppLogProto.numDppEnrolleeResponderSuccess, value);
265     }
266 
267     /**
268      * Test EASY_CONNECT_EVENT_FAILURE_INVALID_URI
269      *
270      * @throws Exception
271      */
272     @Test
testUpdateDppFailureInvalidUri()273     public void testUpdateDppFailureInvalidUri() throws Exception {
274         // Get a random value and call the update method 'value' times
275         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
276 
277         for (int i = 0; i < value; i++) {
278             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_INVALID_URI);
279         }
280 
281         // Confirm that the consolidated log has the expected value
282         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_INVALID_URI, value);
283     }
284 
285     /**
286      * Test EASY_CONNECT_EVENT_FAILURE_AUTHENTICATION
287      *
288      * @throws Exception
289      */
290     @Test
testUpdateDppFailureAuthentication()291     public void testUpdateDppFailureAuthentication() throws Exception {
292         // Get a random value and call the update method 'value' times
293         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
294 
295         for (int i = 0; i < value; i++) {
296             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_AUTHENTICATION);
297         }
298 
299         // Confirm that the consolidated log has the expected value
300         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_AUTHENTICATION,
301                 value);
302     }
303 
304     /**
305      * Test EASY_CONNECT_EVENT_FAILURE_NOT_COMPATIBLE
306      *
307      * @throws Exception
308      */
309     @Test
testUpdateDppFailureNotCompatible()310     public void testUpdateDppFailureNotCompatible() throws Exception {
311         // Get a random value and call the update method 'value' times
312         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
313 
314         for (int i = 0; i < value; i++) {
315             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_NOT_COMPATIBLE);
316         }
317 
318         // Confirm that the consolidated log has the expected value
319         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_NOT_COMPATIBLE,
320                 value);
321     }
322 
323     /**
324      * Test EASY_CONNECT_EVENT_FAILURE_CONFIGURATION
325      *
326      * @throws Exception
327      */
328     @Test
testUpdateDppFailureConfiguration()329     public void testUpdateDppFailureConfiguration() throws Exception {
330         // Get a random value and call the update method 'value' times
331         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
332 
333         for (int i = 0; i < value; i++) {
334             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_CONFIGURATION);
335         }
336 
337         // Confirm that the consolidated log has the expected value
338         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_CONFIGURATION,
339                 value);
340     }
341 
342     /**
343      * Test EASY_CONNECT_EVENT_FAILURE_BUSY
344      *
345      * @throws Exception
346      */
347     @Test
testUpdateDppFailureBusy()348     public void testUpdateDppFailureBusy() throws Exception {
349         // Get a random value and call the update method 'value' times
350         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
351 
352         for (int i = 0; i < value; i++) {
353             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_BUSY);
354         }
355 
356         // Confirm that the consolidated log has the expected value
357         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_BUSY, value);
358     }
359 
360     /**
361      * Test EASY_CONNECT_EVENT_FAILURE_TIMEOUT
362      *
363      * @throws Exception
364      */
365     @Test
testUpdateDppFailureTimeout()366     public void testUpdateDppFailureTimeout() throws Exception {
367         // Get a random value and call the update method 'value' times
368         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
369 
370         for (int i = 0; i < value; i++) {
371             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_TIMEOUT);
372         }
373 
374         // Confirm that the consolidated log has the expected value
375         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_TIMEOUT, value);
376     }
377 
378     /**
379      * Test EASY_CONNECT_EVENT_FAILURE_GENERIC
380      *
381      * @throws Exception
382      */
383     @Test
testUpdateDppFailureGeneric()384     public void testUpdateDppFailureGeneric() throws Exception {
385         // Get a random value and call the update method 'value' times
386         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
387 
388         for (int i = 0; i < value; i++) {
389             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_GENERIC);
390         }
391 
392         // Confirm that the consolidated log has the expected value
393         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_GENERIC, value);
394     }
395 
396     /**
397      * Test EASY_CONNECT_EVENT_FAILURE_NOT_SUPPORTED
398      *
399      * @throws Exception
400      */
401     @Test
testUpdateDppFailureNotSupported()402     public void testUpdateDppFailureNotSupported() throws Exception {
403         // Get a random value and call the update method 'value' times
404         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
405 
406         for (int i = 0; i < value; i++) {
407             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_NOT_SUPPORTED);
408         }
409 
410         // Confirm that the consolidated log has the expected value
411         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_NOT_SUPPORTED,
412                 value);
413     }
414 
415     /**
416      * Test EASY_CONNECT_EVENT_FAILURE_INVALID_NETWORK
417      *
418      * @throws Exception
419      */
420     @Test
testUpdateDppFailureInvalidNetwork()421     public void testUpdateDppFailureInvalidNetwork() throws Exception {
422         // Get a random value and call the update method 'value' times
423         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
424 
425         for (int i = 0; i < value; i++) {
426             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_INVALID_NETWORK);
427         }
428 
429         // Confirm that the consolidated log has the expected value
430         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_INVALID_NETWORK,
431                 value);
432     }
433 
434     /**
435      * Test EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK
436      *
437      * @throws Exception
438      */
439     @Test
testUpdateDppFailureCannotFindNetwork()440     public void testUpdateDppFailureCannotFindNetwork() throws Exception {
441         // Get a random value and call the update method 'value' times
442         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
443 
444         for (int i = 0; i < value; i++) {
445             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK);
446         }
447 
448         // Confirm that the consolidated log has the expected value
449         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK,
450                 value);
451     }
452 
453     /**
454      * Test EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION
455      *
456      * @throws Exception
457      */
458     @Test
testUpdateDppFailureEnrolleeAuthentication()459     public void testUpdateDppFailureEnrolleeAuthentication() throws Exception {
460         // Get a random value and call the update method 'value' times
461         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
462 
463         for (int i = 0; i < value; i++) {
464             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION);
465         }
466 
467         // Confirm that the consolidated log has the expected value
468         checkDppFailures(WifiMetricsProto.WifiDppLog
469                 .EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION, value);
470     }
471 
472     /**
473      * Test
474      * EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION
475      *
476      * @throws Exception
477      */
478     @Test
testUpdateDppFailureEnrolleeRejectedConfiguration()479     public void testUpdateDppFailureEnrolleeRejectedConfiguration() throws Exception {
480         // Get a random value and call the update method 'value' times
481         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
482 
483         for (int i = 0; i < value; i++) {
484             mDppMetrics.updateDppFailure(
485                     EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION);
486         }
487 
488         // Confirm that the consolidated log has the expected value
489         checkDppFailures(WifiMetricsProto.WifiDppLog
490                 .EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION, value);
491     }
492 
493     /**
494      * Test EASY_CONNECT_EVENT_FAILURE_URI_GENERATION
495      *
496      * @throws Exception
497      */
498     @Test
testUpdateDppFailureUriGeneration()499     public void testUpdateDppFailureUriGeneration() throws Exception {
500         assumeTrue(SdkLevel.isAtLeastS());
501         // Get a random value and call the update method 'value' times
502         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
503 
504         for (int i = 0; i < value; i++) {
505             mDppMetrics.updateDppFailure(EASY_CONNECT_EVENT_FAILURE_URI_GENERATION);
506         }
507 
508         // Confirm that the consolidated log has the expected value
509         checkDppFailures(WifiMetricsProto.WifiDppLog.EASY_CONNECT_EVENT_FAILURE_URI_GENERATION,
510                 value);
511     }
512 
513     /**
514      * Test EASY_CONNECT_EVENT_FAILURE_ENROLLEE_FAILED_TO_SCAN_NETWORK_CHANNEL
515      *
516      * @throws Exception
517      */
518     @Test
testUpdateDppFailureEnrolleeFailedToScanNetworkChannel()519     public void testUpdateDppFailureEnrolleeFailedToScanNetworkChannel() throws Exception {
520         assumeTrue(SdkLevel.isAtLeastS());
521         // Get a random value and call the update method 'value' times
522         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
523 
524         for (int i = 0; i < value; i++) {
525             mDppMetrics.updateDppFailure(
526                     EASY_CONNECT_EVENT_FAILURE_ENROLLEE_FAILED_TO_SCAN_NETWORK_CHANNEL);
527         }
528 
529         // Confirm that the consolidated log has the expected value
530         checkDppFailures(WifiMetricsProto
531                 .WifiDppLog.EASY_CONNECT_EVENT_FAILURE_ENROLLEE_FAILED_TO_SCAN_NETWORK_CHANNEL,
532                 value);
533     }
534 
535     /**
536      * Test DPP operation time histogram. Pick a single time value from each bucket by selecting
537      * the max value minus 1, and call the update method random amount of times with this value.
538      * Then confirm that the output histogram has the expected value in each target bucket.
539      *
540      * @throws Exception
541      */
542     @Test
testUpdateHistogramDppOperationTime()543     public void testUpdateHistogramDppOperationTime() throws Exception {
544         // Iterate through the histogram array
545         for (int i = 0; i <= DPP_OPERATION_TIME.length; i++) {
546             // Get a random value and call the operation time update method
547             int value = getNumOfTimes(MAX_ITERATIONS) + 1;
548             int timeMs;
549 
550             if (i < DPP_OPERATION_TIME.length) {
551                 timeMs = DPP_OPERATION_TIME[i] - 1;
552             } else {
553                 timeMs = DPP_OPERATION_TIME[i - 1];
554             }
555 
556             // Framework uses milliseconds when it gets the time, convert to milliseconds
557             timeMs *= 1000;
558 
559             for (int j = 0; j < value; j++) {
560                 // Add a time value that would fall in the i'th bucket
561                 mDppMetrics.updateDppOperationTime(timeMs);
562             }
563 
564             // Confirm that output matches the expected value
565             checkOperationBucketEqualsTo(i, value);
566         }
567     }
568 
569     /**
570      * Test numDppR1CapableEnrolleeResponderDevices
571      *
572      * @throws Exception
573      */
574     @Test
testUpdateDppR1CapableEnrolleeResponderDevices()575     public void testUpdateDppR1CapableEnrolleeResponderDevices() throws Exception {
576         // Get a random value and call the update method 'value' times
577         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
578 
579         for (int i = 0; i < value; i++) {
580             mDppMetrics.updateDppR1CapableEnrolleeResponderDevices();
581         }
582 
583         // Confirm that the consolidated log has the expected value
584         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
585         assertEquals(mWifiDppLogProto.numDppR1CapableEnrolleeResponderDevices, value);
586     }
587 
588     /**
589      * Test numDppR2CapableEnrolleeResponderDevices
590      *
591      * @throws Exception
592      */
593     @Test
testUpdateDppR2CapableEnrolleeResponderDevices()594     public void testUpdateDppR2CapableEnrolleeResponderDevices() throws Exception {
595         // Get a random value and call the update method 'value' times
596         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
597 
598         for (int i = 0; i < value; i++) {
599             mDppMetrics.updateDppR2CapableEnrolleeResponderDevices();
600         }
601 
602         // Confirm that the consolidated log has the expected value
603         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
604         assertEquals(mWifiDppLogProto.numDppR2CapableEnrolleeResponderDevices, value);
605     }
606 
607     /**
608      * Test numDppR2EnrolleeResponderIncompatibleConfiguration
609      *
610      * @throws Exception
611      */
612     @Test
testUpdateDppR2EnrolleeResponderIncompatibleConfiguration()613     public void testUpdateDppR2EnrolleeResponderIncompatibleConfiguration() throws Exception {
614         // Get a random value and call the update method 'value' times
615         int value = getNumOfTimes(MAX_ITERATIONS) + 1;
616 
617         for (int i = 0; i < value; i++) {
618             mDppMetrics.updateDppR2EnrolleeResponderIncompatibleConfiguration();
619         }
620 
621         // Confirm that the consolidated log has the expected value
622         WifiMetricsProto.WifiDppLog mWifiDppLogProto = mDppMetrics.consolidateProto();
623         assertEquals(mWifiDppLogProto.numDppR2EnrolleeResponderIncompatibleConfiguration, value);
624     }
625 }
626