OSDN Git Service

android-2.1_r1 snapshot
[android-x86/sdk.git] / eclipse / plugins / com.android.ide.eclipse.tests / unittests / com / android / ide / eclipse / adt / internal / editors / resources / configurations / ScreenOrientationQualifierTest.java
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
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
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
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.eclipse.adt.internal.editors.resources.configurations;
18
19 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
20 import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
21
22 import junit.framework.TestCase;
23
24 public class ScreenOrientationQualifierTest extends TestCase {
25
26     private ScreenOrientationQualifier soq;
27     private FolderConfiguration config;
28
29     @Override
30     protected void setUp() throws Exception {
31         super.setUp();
32         soq = new ScreenOrientationQualifier();
33         config = new FolderConfiguration();
34     }
35
36     @Override
37     protected void tearDown() throws Exception {
38         super.tearDown();
39         soq = null;
40         config = null;
41     }
42
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$
49     }
50
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$
57     }
58
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$
65     }
66
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$
73     }
74 }