2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Eclipse Public License, Version 1.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
8 * http://www.eclipse.org/org/documents/epl-v10.php
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.
17 package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
19 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
20 import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
22 import junit.framework.TestCase;
24 public class ScreenOrientationQualifierTest extends TestCase {
26 private ScreenOrientationQualifier soq;
27 private FolderConfiguration config;
30 protected void setUp() throws Exception {
32 soq = new ScreenOrientationQualifier();
33 config = new FolderConfiguration();
37 protected void tearDown() throws Exception {
43 public void testPortrait() {
44 assertEquals(true, soq.checkAndSet("port", config)); //$NON-NLS-1$
45 assertTrue(config.getScreenOrientationQualifier() != null);
46 assertEquals(ScreenOrientationQualifier.ScreenOrientation.PORTRAIT,
47 config.getScreenOrientationQualifier().getValue());
48 assertEquals("port", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
51 public void testLanscape() {
52 assertEquals(true, soq.checkAndSet("land", config)); //$NON-NLS-1$
53 assertTrue(config.getScreenOrientationQualifier() != null);
54 assertEquals(ScreenOrientationQualifier.ScreenOrientation.LANDSCAPE,
55 config.getScreenOrientationQualifier().getValue());
56 assertEquals("land", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
59 public void testSquare() {
60 assertEquals(true, soq.checkAndSet("square", config)); //$NON-NLS-1$
61 assertTrue(config.getScreenOrientationQualifier() != null);
62 assertEquals(ScreenOrientationQualifier.ScreenOrientation.SQUARE,
63 config.getScreenOrientationQualifier().getValue());
64 assertEquals("square", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
67 public void testFailures() {
68 assertEquals(false, soq.checkAndSet("", config));//$NON-NLS-1$
69 assertEquals(false, soq.checkAndSet("PORT", config));//$NON-NLS-1$
70 assertEquals(false, soq.checkAndSet("landscape", config));//$NON-NLS-1$
71 assertEquals(false, soq.checkAndSet("portrait", config));//$NON-NLS-1$
72 assertEquals(false, soq.checkAndSet("other", config));//$NON-NLS-1$