OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / sdk / eclipse / plugins / com.android.ide.eclipse.tests / unittests / com / android / ide / eclipse / adt / internal / editors / resources / configurations / CountryCodeQualifierTest.java
1 /*
2  * Copyright (C) 2008 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.CountryCodeQualifier;
20 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
21
22 import junit.framework.TestCase;
23
24 public class CountryCodeQualifierTest extends TestCase {
25
26     private CountryCodeQualifier mccq;
27     private FolderConfiguration config;
28
29     @Override
30     protected void setUp() throws Exception {
31         super.setUp();
32         mccq = new CountryCodeQualifier();
33         config = new FolderConfiguration();
34     }
35
36     @Override
37     protected void tearDown() throws Exception {
38         super.tearDown();
39         mccq = null;
40         config = null;
41     }
42
43     public void testCheckAndSet() {
44         assertEquals(true, mccq.checkAndSet("mcc123", config));//$NON-NLS-1$
45         assertTrue(config.getCountryCodeQualifier() != null);
46         assertEquals(123, config.getCountryCodeQualifier().getCode());
47         assertEquals("mcc123", config.getCountryCodeQualifier().toString()); //$NON-NLS-1$
48     }
49
50     public void testFailures() {
51         assertEquals(false, mccq.checkAndSet("", config));//$NON-NLS-1$
52         assertEquals(false, mccq.checkAndSet("mcc", config));//$NON-NLS-1$
53         assertEquals(false, mccq.checkAndSet("MCC123", config));//$NON-NLS-1$
54         assertEquals(false, mccq.checkAndSet("123", config));//$NON-NLS-1$
55         assertEquals(false, mccq.checkAndSet("mccsdf", config));//$NON-NLS-1$
56     }
57
58 }