1/*
2 * Copyright (C) 2015 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
17package androidx.appcompat.app;
18
19import static org.junit.Assert.assertNotNull;
20import static org.junit.Assert.assertTrue;
21
22import android.support.test.filters.SmallTest;
23import android.support.test.runner.AndroidJUnit4;
24
25import androidx.appcompat.view.menu.MenuBuilder;
26
27import org.junit.Test;
28import org.junit.runner.RunWith;
29
30import java.lang.reflect.Method;
31import java.lang.reflect.Modifier;
32
33@RunWith(AndroidJUnit4.class)
34@SmallTest
35public class MenuBuilderTest {
36
37    @Test
38    public void setOptionalIconsVisibleMethodShouldRemainPublic() throws Exception {
39        // This test is to verify workaround for bug in the ROM of Explay Fresh devices with 4.2.2 ROM.
40        // Manufacturer has modified ROM and added a public method setOptionalIconsVisible
41        // to android.view.Menu interface. Because of that the runtime can't load MenuBuilder class
42        // because it had no such public method (it was package local)
43        Method method = MenuBuilder.class
44                .getMethod("setOptionalIconsVisible", boolean.class);
45        assertNotNull(method);
46        assertTrue(Modifier.isPublic(method.getModifiers()));
47    }
48}
49
50