| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.preferences; | 5 package org.chromium.chrome.browser.preferences; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.Fragment; | |
| 9 import android.app.Instrumentation; | 8 import android.app.Instrumentation; |
| 10 import android.app.Notification; | |
| 11 import android.content.Context; | 9 import android.content.Context; |
| 12 import android.content.Intent; | 10 import android.content.Intent; |
| 13 import android.preference.Preference; | 11 import android.preference.Preference; |
| 14 import android.preference.PreferenceFragment; | 12 import android.preference.PreferenceFragment; |
| 15 import android.preference.PreferenceScreen; | 13 import android.preference.PreferenceScreen; |
| 16 import android.test.suitebuilder.annotation.SmallTest; | 14 import android.test.suitebuilder.annotation.SmallTest; |
| 17 | 15 |
| 18 import org.chromium.base.ThreadUtils; | 16 import org.chromium.base.ThreadUtils; |
| 19 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
| 20 import org.chromium.chrome.browser.accessibility.FontSizePrefs; | 18 import org.chromium.chrome.browser.accessibility.FontSizePrefs; |
| 21 import org.chromium.chrome.browser.preferences.website.WebsitePreferences; | |
| 22 import org.chromium.chrome.browser.search_engines.TemplateUrlService; | 19 import org.chromium.chrome.browser.search_engines.TemplateUrlService; |
| 23 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene
r; | 20 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene
r; |
| 24 import org.chromium.chrome.shell.ChromeShellTestBase; | 21 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 25 import org.chromium.chrome.shell.preferences.ChromeShellMainPreferences; | 22 import org.chromium.chrome.shell.preferences.ChromeShellMainPreferences; |
| 26 import org.chromium.content.browser.test.util.CallbackHelper; | 23 import org.chromium.content.browser.test.util.CallbackHelper; |
| 27 import org.chromium.content.browser.test.util.UiUtils; | 24 import org.chromium.content.browser.test.util.UiUtils; |
| 28 | 25 |
| 29 import java.lang.reflect.Method; | 26 import java.lang.reflect.Method; |
| 30 import java.text.NumberFormat; | 27 import java.text.NumberFormat; |
| 31 | 28 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Simulate selecting the third search engine and ensure that Te
mplateUrlService | 115 // Simulate selecting the third search engine and ensure that Te
mplateUrlService |
| 119 // is updated. | 116 // is updated. |
| 120 if (pref.getOnPreferenceChangeListener().onPreferenceChange(pref
, "2")) { | 117 if (pref.getOnPreferenceChangeListener().onPreferenceChange(pref
, "2")) { |
| 121 pref.setValue("2"); | 118 pref.setValue("2"); |
| 122 } | 119 } |
| 123 assertEquals(2, TemplateUrlService.getInstance().getDefaultSearc
hEngineIndex()); | 120 assertEquals(2, TemplateUrlService.getInstance().getDefaultSearc
hEngineIndex()); |
| 124 } | 121 } |
| 125 }); | 122 }); |
| 126 } | 123 } |
| 127 | 124 |
| 128 /** | 125 // TODO(mvanouwerkerk): Write new preference intent tests for notification s
ettings. |
| 129 * Starts the preference activity as if it's been opened from the App Notifi
cation settings | 126 // https://crbug.com/461885 |
| 130 * screen to verify that it opens the Notifications Site Settings screen. | |
| 131 */ | |
| 132 @SmallTest | |
| 133 @Feature({"Preferences"}) | |
| 134 public void testNotificationSettingsCategoryIntent() throws Exception { | |
| 135 Instrumentation instrumentation = getInstrumentation(); | |
| 136 | |
| 137 Intent intent = PreferencesLauncher.createIntentForSettingsPage( | |
| 138 instrumentation.getTargetContext(), null); | |
| 139 intent.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES
); | |
| 140 | |
| 141 Activity activity = instrumentation.startActivitySync(intent); | |
| 142 assertTrue(activity instanceof Preferences); | |
| 143 | |
| 144 Fragment fragment = ((Preferences) activity).getFragmentForTest(); | |
| 145 assertTrue(fragment instanceof WebsitePreferences); | |
| 146 } | |
| 147 | 127 |
| 148 /** | 128 /** |
| 149 * Tests setting FontScaleFactor and ForceEnableZoom in AccessibilityPrefere
nces and ensures | 129 * Tests setting FontScaleFactor and ForceEnableZoom in AccessibilityPrefere
nces and ensures |
| 150 * that ForceEnableZoom changes corresponding to FontScaleFactor. | 130 * that ForceEnableZoom changes corresponding to FontScaleFactor. |
| 151 */ | 131 */ |
| 152 @SmallTest | 132 @SmallTest |
| 153 @Feature({"Accessibility"}) | 133 @Feature({"Accessibility"}) |
| 154 public void testAccessibilityPreferences() throws Exception { | 134 public void testAccessibilityPreferences() throws Exception { |
| 155 String accessibilityPrefClassname = AccessibilityPreferences.class.getNa
me(); | 135 String accessibilityPrefClassname = AccessibilityPreferences.class.getNa
me(); |
| 156 AccessibilityPreferences accessibilityPref = (AccessibilityPreferences) | 136 AccessibilityPreferences accessibilityPref = (AccessibilityPreferences) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 private static void userSetForceEnableZoom(final AccessibilityPreferences ac
cessibilityPref, | 202 private static void userSetForceEnableZoom(final AccessibilityPreferences ac
cessibilityPref, |
| 223 final SeekBarLinkedCheckBoxPreference forceEnableZoomPref, final boo
lean enabled) { | 203 final SeekBarLinkedCheckBoxPreference forceEnableZoomPref, final boo
lean enabled) { |
| 224 ThreadUtils.runOnUiThread(new Runnable() { | 204 ThreadUtils.runOnUiThread(new Runnable() { |
| 225 @Override | 205 @Override |
| 226 public void run() { | 206 public void run() { |
| 227 accessibilityPref.onPreferenceChange(forceEnableZoomPref, enable
d); | 207 accessibilityPref.onPreferenceChange(forceEnableZoomPref, enable
d); |
| 228 } | 208 } |
| 229 }); | 209 }); |
| 230 } | 210 } |
| 231 } | 211 } |
| OLD | NEW |