OSDN Git Service

Update strings.
authorFan Zhang <zhfan@google.com>
Mon, 28 Nov 2016 20:38:11 +0000 (12:38 -0800)
committerFan Zhang <zhfan@google.com>
Mon, 28 Nov 2016 20:48:07 +0000 (12:48 -0800)
Bug: 32841662
Test: RunSettingsRoboTests
Change-Id: I178070bfd5f20188e580f8a3a8dd442bd17f3632

res/values/strings.xml
tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java [new file with mode: 0644]

index 3c9a4cc..078b646 100644 (file)
     <string name="bluetooth_phonebook_request">"Phone book access request"</string>
 
     <!-- Bluetooth phone book permission Alert Activity text [CHAR LIMIT=none] -->
-    <string name="bluetooth_pb_acceptance_dialog_text">%1$s wants to access your contacts and call history. Give access to %2$s?</string>
+    <string name="bluetooth_pb_acceptance_dialog_text">
+        <xliff:g id="device_name">%1$s</xliff:g> wants to access your contacts and call history. Give access to <xliff:g id="device_name">%2$s</xliff:g>?
+    </string>
 
     <!-- Bluetooth phone book permission Alert Activity checkbox text [CHAR LIMIT=none] -->
     <string name="bluetooth_remember_choice">Don\u2019t ask again</string>
     <string name="mobile_unknown_sim_operator" translatable="true">Unknown SIM operator</string>
 
     <!-- There is no mobile provisiong website for the operator which is the firat parameter [CHAR_ LIMIT=50]-->
-    <string name="mobile_no_provisioning_url" translatable="true">%1$s has no known provisioning website</string>
+    <string name="mobile_no_provisioning_url"><xliff:g id="operator">%1$s</xliff:g> has no known provisioning website</string>
 
     <!-- Ask user to insert a SIM card [CHAR_ LIMIT=50]-->
     <string name="mobile_insert_sim_card" translatable="true">Please insert SIM card and restart</string>
     <string name="battery_saver_turn_on_automatically_never">Never</string>
 
     <!-- [CHAR_LIMIT=40] Battery saver: Value for automatic entry option: pct% battery -->
-    <string name="battery_saver_turn_on_automatically_pct">at %1$s battery</string>
+    <string name="battery_saver_turn_on_automatically_pct">at <xliff:g id="percent">%1$s</xliff:g>battery</string>
 
     <!-- Process Stats strings -->
     <skip />
index 035d29e..90f2106 100644 (file)
 package com.android.settings.bluetooth;
 
 import android.app.AlertDialog;
+import android.content.Context;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.CheckBox;
 import android.widget.TextView;
+
 import com.android.settings.R;
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.FragmentTestUtil;
 
 import static com.google.common.truth.Truth.assertThat;
@@ -330,6 +334,14 @@ public class BluetoothPairingDialogTest {
         assertThat(message.getVisibility()).isEqualTo(View.GONE);
     }
 
+    @Test
+    public void pairingStringIsFormattedCorrectly() {
+        final String device = "test_device";
+        final Context context = ShadowApplication.getInstance().getApplicationContext();
+        assertThat(context.getString(R.string.bluetooth_pb_acceptance_dialog_text, device, device))
+                .contains(device);
+    }
+
     private BluetoothPairingDialogFragment makeFragment() {
         BluetoothPairingDialogFragment frag = new BluetoothPairingDialogFragment();
         frag.setPairingController(controller);
diff --git a/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
new file mode 100644 (file)
index 0000000..5827c8b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class MobilePlanPreferenceControllerTest {
+
+    @Test
+    public void testNoProvisionStringFormattedCorrectly() {
+        final String operator = "test_operator";
+        final Context context = ShadowApplication.getInstance().getApplicationContext();
+        assertThat(context.getString(R.string.mobile_no_provisioning_url, operator, operator))
+                .contains(operator);
+    }
+}