| 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.dom_distiller; | 5 package org.chromium.chrome.browser.dom_distiller; |
| 6 | 6 |
| 7 import android.test.UiThreadTest; |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.test.UiThreadTest; | |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| 11 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.chrome.browser.profiles.Profile; | 12 import org.chromium.chrome.browser.profiles.Profile; |
| 13 import org.chromium.chrome.shell.ChromeShellTestBase; | 13 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 14 import org.chromium.components.dom_distiller.core.DistilledPagePrefs; | 14 import org.chromium.components.dom_distiller.core.DistilledPagePrefs; |
| 15 import org.chromium.components.dom_distiller.core.DomDistillerService; | 15 import org.chromium.components.dom_distiller.core.DomDistillerService; |
| 16 import org.chromium.components.dom_distiller.core.FontFamily; | 16 import org.chromium.components.dom_distiller.core.FontFamily; |
| 17 import org.chromium.components.dom_distiller.core.Theme; | 17 import org.chromium.components.dom_distiller.core.Theme; |
| 18 import org.chromium.content.browser.test.util.UiUtils; | 18 import org.chromium.content.browser.test.util.UiUtils; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Test class for {@link DistilledPagePrefs}. | 21 * Test class for {@link DistilledPagePrefs}. |
| 22 */ | 22 */ |
| 23 public class DistilledPagePrefsTest extends ChromeShellTestBase { | 23 public class DistilledPagePrefsTest extends ChromeShellTestBase { |
| 24 | 24 |
| 25 private DistilledPagePrefs mDistilledPagePrefs; | 25 private DistilledPagePrefs mDistilledPagePrefs; |
| 26 | 26 |
| 27 @Override | 27 @Override |
| 28 public void setUp() throws Exception { | 28 public void setUp() throws Exception { |
| 29 super.setUp(); | 29 super.setUp(); |
| 30 startChromeBrowserProcessSync(getInstrumentation().getTargetContext()); | 30 startChromeBrowserProcessSync(getInstrumentation().getTargetContext()); |
| 31 getDistilledPagePrefs(); | 31 getDistilledPagePrefs(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 private void getDistilledPagePrefs() { | 34 private void getDistilledPagePrefs() { |
| 35 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 35 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 36 @Override |
| 36 public void run() { | 37 public void run() { |
| 37 DomDistillerService domDistillerService = DomDistillerServiceFac
tory. | 38 DomDistillerService domDistillerService = DomDistillerServiceFac
tory. |
| 38 getForProfile(Profile.getLastUsedProfile()); | 39 getForProfile(Profile.getLastUsedProfile()); |
| 39 mDistilledPagePrefs = domDistillerService.getDistilledPagePrefs(
); | 40 mDistilledPagePrefs = domDistillerService.getDistilledPagePrefs(
); |
| 40 } | 41 } |
| 41 }); | 42 }); |
| 42 } | 43 } |
| 43 | 44 |
| 44 @SmallTest | 45 @SmallTest |
| 45 @UiThreadTest | 46 @UiThreadTest |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 private static class TestingObserver implements DistilledPagePrefs.Observer
{ | 161 private static class TestingObserver implements DistilledPagePrefs.Observer
{ |
| 161 private FontFamily mFontFamily; | 162 private FontFamily mFontFamily; |
| 162 private Theme mTheme; | 163 private Theme mTheme; |
| 163 | 164 |
| 164 public TestingObserver() {} | 165 public TestingObserver() {} |
| 165 | 166 |
| 166 public FontFamily getFontFamily() { | 167 public FontFamily getFontFamily() { |
| 167 return mFontFamily; | 168 return mFontFamily; |
| 168 } | 169 } |
| 169 | 170 |
| 171 @Override |
| 170 public void onChangeFontFamily(FontFamily font) { | 172 public void onChangeFontFamily(FontFamily font) { |
| 171 mFontFamily = font; | 173 mFontFamily = font; |
| 172 } | 174 } |
| 173 | 175 |
| 174 public Theme getTheme() { | 176 public Theme getTheme() { |
| 175 return mTheme; | 177 return mTheme; |
| 176 } | 178 } |
| 177 | 179 |
| 180 @Override |
| 178 public void onChangeTheme(Theme theme) { | 181 public void onChangeTheme(Theme theme) { |
| 179 mTheme = theme; | 182 mTheme = theme; |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 | 185 |
| 183 private void setFontFamily(final FontFamily font) { | 186 private void setFontFamily(final FontFamily font) { |
| 184 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 187 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 188 @Override |
| 185 public void run() { | 189 public void run() { |
| 186 mDistilledPagePrefs.setFontFamily(font); | 190 mDistilledPagePrefs.setFontFamily(font); |
| 187 } | 191 } |
| 188 }); | 192 }); |
| 189 } | 193 } |
| 190 | 194 |
| 191 private void setTheme(final Theme theme) { | 195 private void setTheme(final Theme theme) { |
| 192 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 196 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 197 @Override |
| 193 public void run() { | 198 public void run() { |
| 194 mDistilledPagePrefs.setTheme(theme); | 199 mDistilledPagePrefs.setTheme(theme); |
| 195 } | 200 } |
| 196 }); | 201 }); |
| 197 } | 202 } |
| 198 } | 203 } |
| OLD | NEW |