Debian Codegraph @

sdk-common/src/test/java/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java

raw
1 /*
2 * Copyright (C) 2007 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.ide.common.resources.configuration;
18
19 import com.android.resources.Navigation;
20
21 import junit.framework.TestCase;
22
23 public class NavigationMethodQualifierTest extends TestCase {
24
25 private FolderConfiguration config;
26 private NavigationMethodQualifier nmq;
27
28 @Override
29 public void setUp() throws Exception {
30 super.setUp();
31 config = new FolderConfiguration();
32 nmq = new NavigationMethodQualifier();
33 }
34
35 @Override
36 protected void tearDown() throws Exception {
37 super.tearDown();
38 config = null;
39 nmq = null;
40 }
41
42 public void testDPad() {
43 assertEquals(true, nmq.checkAndSet("dpad", config)); //$NON-NLS-1$
44 assertTrue(config.getNavigationMethodQualifier() != null);
45 assertEquals(Navigation.DPAD, config.getNavigationMethodQualifier().getValue());
46 assertEquals("dpad", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
47 }
48
49 public void testTrackball() {
50 assertEquals(true, nmq.checkAndSet("trackball", config)); //$NON-NLS-1$
51 assertTrue(config.getNavigationMethodQualifier() != null);
52 assertEquals(Navigation.TRACKBALL, config.getNavigationMethodQualifier().getValue());
53 assertEquals("trackball", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
54 }
55
56 public void testWheel() {
57 assertEquals(true, nmq.checkAndSet("wheel", config)); //$NON-NLS-1$
58 assertTrue(config.getNavigationMethodQualifier() != null);
59 assertEquals(Navigation.WHEEL, config.getNavigationMethodQualifier().getValue());
60 assertEquals("wheel", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
61 }
62
63 public void testFailures() {
64 assertEquals(false, nmq.checkAndSet("", config));//$NON-NLS-1$
65 assertEquals(false, nmq.checkAndSet("WHEEL", config));//$NON-NLS-1$
66 assertEquals(false, nmq.checkAndSet("other", config));//$NON-NLS-1$
67 }
68 }