Home | History | Annotate | Download | only in deviceinfo
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      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 package com.android.compatibility.common.deviceinfo;
     17 
     18 /**
     19  * Example Objects for {@link DeviceInfo} test package.
     20  */
     21 public final class ExampleObjects {
     22 
     23     // Must match DeviceInfo.MAX_STRING_VALUE_LENGTH and
     24     // DeviceInfo.MAX_ARRAY_LENGTH
     25     private static final int MAX_LENGTH = 1000;
     26 
     27     private static final String TEST_DEVICE_INFO_JSON = "{\n" +
     28         "  \"test_boolean\": true,\n" +
     29         "  \"test_double\": 1.23456789,\n" +
     30         "  \"test_int\": 123456789,\n" +
     31         "  \"test_long\": 9223372036854775807,\n" +
     32         "  \"test_string\": \"test string\",\n" +
     33         "  \"test_strings\": [\n" +
     34         "    \"test string 1\",\n" +
     35         "    \"test string 2\",\n" +
     36         "    \"test string 3\"\n" +
     37         "  ],\n" +
     38         "  \"test_group\": {\n" +
     39         "    \"test_boolean\": false,\n" +
     40         "    \"test_double\": 9.87654321,\n" +
     41         "    \"test_int\": 987654321,\n" +
     42         "    \"test_long\": 9223372036854775807,\n" +
     43         "    \"test_string\": \"test group string\",\n" +
     44         "    \"test_strings\": [\n" +
     45         "      \"test group string 1\",\n" +
     46         "      \"test group string 2\",\n" +
     47         "      \"test group string 3\"\n" +
     48         "    ]\n" +
     49         "  },\n" +
     50         "  \"test_groups\": [\n" +
     51         "    {\n" +
     52         "      \"test_string\": \"test groups string 1\",\n" +
     53         "      \"test_strings\": [\n" +
     54         "        \"test groups string 1-1\",\n" +
     55         "        \"test groups string 1-2\",\n" +
     56         "        \"test groups string 1-3\"\n" +
     57         "      ]\n" +
     58         "    },\n" +
     59         "    {\n" +
     60         "      \"test_string\": \"test groups string 2\",\n" +
     61         "      \"test_strings\": [\n" +
     62         "        \"test groups string 2-1\",\n" +
     63         "        \"test groups string 2-2\",\n" +
     64         "        \"test groups string 2-3\"\n" +
     65         "      ]\n" +
     66         "    },\n" +
     67         "    {\n" +
     68         "      \"test_string\": \"test groups string 3\",\n" +
     69         "      \"test_strings\": [\n" +
     70         "        \"test groups string 3-1\",\n" +
     71         "        \"test groups string 3-2\",\n" +
     72         "        \"test groups string 3-3\"\n" +
     73         "      ]\n" +
     74         "    }\n" +
     75         "  ],\n" +
     76         "  \"max_length_string\": \"%s\",\n" +
     77         "  \"max_num_ints\": [\n%s" +
     78         "  ]\n" +
     79         "}\n";
     80 
     81     public static String testDeviceInfoJson() {
     82         StringBuilder longStringSb = new StringBuilder();
     83         StringBuilder longArraySb = new StringBuilder();
     84         int lastNum = MAX_LENGTH - 1;
     85         for (int i = 0; i < MAX_LENGTH; i++) {
     86             longStringSb.append("a");
     87             longArraySb.append(String.format("    %d%s\n", i, ((i == lastNum)? "" : ",")));
     88         }
     89         return String.format(TEST_DEVICE_INFO_JSON,
     90             longStringSb.toString(), longArraySb.toString());
     91     }
     92 }