2 * Copyright (C) 2010 Google Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.i18n.addressinput;
19 import junit.framework.TestCase;
22 * Test for building form options.
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));
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));
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));