blob: f6ea73cc4ebcfc31c55793106992f60774379590 [file] [log] [blame]
Jinseong Jeone11145f2018-12-13 10:57:29 -08001// Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package mockito_interface;
5
6import static org.mockito.Mockito.times;
7import static org.mockito.Mockito.verify;
8
Jinseong Jeone11145f2018-12-13 10:57:29 -08009import org.mockito.Mock;
10import org.mockito.MockitoAnnotations;
11
Jinseong Jeone11145f2018-12-13 10:57:29 -080012public class InterfaceTest {
Ian Zernyacb4f322022-04-08 12:40:00 +020013
Jinseong Jeone11145f2018-12-13 10:57:29 -080014 @Mock
15 private Interface fld;
16
17 private InterfaceUser user;
18
19 private boolean flag;
20
Ian Zernyacb4f322022-04-08 12:40:00 +020021 public static void main(String[] args) {
22 for (boolean flag : new boolean[] {true, false}) {
23 InterfaceTest test = new InterfaceTest(flag);
24 test.setUp();
25 test.test();
26 }
Jinseong Jeone11145f2018-12-13 10:57:29 -080027 }
28
29 public InterfaceTest(boolean flag) {
30 this.flag = flag;
31 }
32
Jinseong Jeone11145f2018-12-13 10:57:29 -080033 public void setUp() {
34 MockitoAnnotations.initMocks(this);
35 user = new InterfaceUser(fld);
36 }
37
Jinseong Jeone11145f2018-12-13 10:57:29 -080038 public void test() {
39 if (flag) {
40 user.consume();
41 }
42 verify(fld, times(flag ? 1 : 0)).onEnterForeground();
43 }
44}