Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / third_party / libaddressinput / src / java / test / com / android / i18n / addressinput / FormOptionsTest.java
1 /*
2  * Copyright (C) 2010 Google Inc.
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.i18n.addressinput;
18
19 import junit.framework.TestCase;
20
21 /**
22  * Test for building form options.
23  */
24 public class FormOptionsTest extends TestCase {
25     public void testRequiredField() throws Exception {
26         FormOptions options = new FormOptions.Builder().required(AddressField.COUNTRY).build();
27         assertTrue(options.isRequired(AddressField.COUNTRY));
28         assertFalse(options.isRequired(AddressField.LOCALITY));
29         assertTrue(options.getRequiredFields().contains(AddressField.COUNTRY));
30         assertFalse(options.getRequiredFields().contains(AddressField.LOCALITY));
31     }
32
33     public void testReadonlyField() throws Exception {
34         FormOptions options = new FormOptions.Builder().readonly(AddressField.COUNTRY).build();
35         assertTrue(options.isReadonly(AddressField.COUNTRY));
36         assertFalse(options.isReadonly(AddressField.LOCALITY));
37     }
38
39     public void testHiddenField() throws Exception {
40         FormOptions options = new FormOptions.Builder().hide(AddressField.COUNTRY).build();
41         assertTrue(options.isHidden(AddressField.COUNTRY));
42         assertFalse(options.isHidden(AddressField.LOCALITY));
43     }
44 }