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 / PixelDensityQualifierTest.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.PixelDensityQualifier;
21 import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier.Density;
22
23 import junit.framework.TestCase;
24
25 public class PixelDensityQualifierTest extends TestCase {
26
27     private PixelDensityQualifier pdq;
28     private FolderConfiguration config;
29
30     @Override
31     protected void setUp() throws Exception {
32         super.setUp();
33         pdq = new PixelDensityQualifier();
34         config = new FolderConfiguration();
35     }
36
37     @Override
38     protected void tearDown() throws Exception {
39         super.tearDown();
40         pdq = null;
41         config = null;
42     }
43
44     public void testCheckAndSet() {
45         assertEquals(true, pdq.checkAndSet("ldpi", config));//$NON-NLS-1$
46         assertTrue(config.getPixelDensityQualifier() != null);
47         assertEquals(Density.LOW, config.getPixelDensityQualifier().getValue());
48         assertEquals("ldpi", config.getPixelDensityQualifier().toString()); //$NON-NLS-1$
49     }
50
51     public void testFailures() {
52         assertEquals(false, pdq.checkAndSet("", config));//$NON-NLS-1$
53         assertEquals(false, pdq.checkAndSet("dpi", config));//$NON-NLS-1$
54         assertEquals(false, pdq.checkAndSet("123dpi", config));//$NON-NLS-1$
55         assertEquals(false, pdq.checkAndSet("123", config));//$NON-NLS-1$
56         assertEquals(false, pdq.checkAndSet("sdfdpi", config));//$NON-NLS-1$
57     }
58
59 }