| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import org.junit.runner.Description; | 7 import org.junit.runner.Description; |
| 8 import org.junit.runners.model.Statement; | 8 import org.junit.runners.model.Statement; |
| 9 | 9 |
| 10 import org.chromium.base.test.SetUpStatement; |
| 11 import org.chromium.base.test.SetUpTestRule; |
| 10 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 12 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
| 11 import org.chromium.content_shell_apk.ContentShellActivity; | 13 import org.chromium.content_shell_apk.ContentShellActivity; |
| 12 import org.chromium.content_shell_apk.ContentShellActivityTestRule; | 14 import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
| 13 import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback; | 15 import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback; |
| 14 | 16 |
| 15 import java.lang.annotation.Annotation; | 17 import java.lang.annotation.Annotation; |
| 16 | 18 |
| 17 /** | 19 /** |
| 18 * ActivityTestRule with common functionality for testing the Java Bridge. | 20 * ActivityTestRule with common functionality for testing the Java Bridge. |
| 19 */ | 21 */ |
| 20 public class JavaBridgeActivityTestRule | 22 public class JavaBridgeActivityTestRule |
| 21 extends ContentShellActivityTestRule implements TestCommonCallback<Conte
ntShellActivity> { | 23 extends ContentShellActivityTestRule implements TestCommonCallback<Conte
ntShellActivity>, |
| 24 SetUpTestRule<JavaBridge
ActivityTestRule> { |
| 22 private JavaBridgeTestCommon mTestCommon; | 25 private JavaBridgeTestCommon mTestCommon; |
| 26 private boolean mSetup = false; |
| 23 | 27 |
| 24 public JavaBridgeActivityTestRule() { | 28 public JavaBridgeActivityTestRule() { |
| 25 super(); | 29 super(); |
| 26 mTestCommon = new JavaBridgeTestCommon(this); | 30 mTestCommon = new JavaBridgeTestCommon(this); |
| 27 } | 31 } |
| 28 | 32 |
| 29 /** | 33 /** |
| 30 * Sets up the ContentView. Intended to be called from setUp(). | 34 * Sets up the ContentView. Intended to be called from setUp(). |
| 31 */ | 35 */ |
| 32 private void setUpContentView() { | 36 public void setUpContentView() { |
| 33 mTestCommon.setUpContentView(); | 37 mTestCommon.setUpContentView(); |
| 34 } | 38 } |
| 35 | 39 |
| 36 public TestCallbackHelperContainer getTestCallBackHelperContainer() { | 40 public TestCallbackHelperContainer getTestCallBackHelperContainer() { |
| 37 return mTestCommon.getTestCallBackHelperContainer(); | 41 return mTestCommon.getTestCallBackHelperContainer(); |
| 38 } | 42 } |
| 39 | 43 |
| 40 public void executeJavaScript(String script) throws Throwable { | 44 public void executeJavaScript(String script) throws Throwable { |
| 41 mTestCommon.executeJavaScript(script); | 45 mTestCommon.executeJavaScript(script); |
| 42 } | 46 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 final Object object2, final String name2, | 58 final Object object2, final String name2, |
| 55 final Class<? extends Annotation> requiredAnnotation) throws Excepti
on { | 59 final Class<? extends Annotation> requiredAnnotation) throws Excepti
on { |
| 56 mTestCommon.injectObjectsAndReload(object1, name1, object2, name2, requi
redAnnotation); | 60 mTestCommon.injectObjectsAndReload(object1, name1, object2, name2, requi
redAnnotation); |
| 57 } | 61 } |
| 58 | 62 |
| 59 public void synchronousPageReload() throws Throwable { | 63 public void synchronousPageReload() throws Throwable { |
| 60 mTestCommon.synchronousPageReload(); | 64 mTestCommon.synchronousPageReload(); |
| 61 } | 65 } |
| 62 | 66 |
| 63 @Override | 67 @Override |
| 64 public Statement apply(final Statement base, Description desc) { | 68 public Statement apply(Statement base, Description desc) { |
| 65 return super.apply(new Statement() { | 69 SetUpStatement setUpBase = new SetUpStatement(base, this, mSetup); |
| 66 @Override | 70 return super.apply(setUpBase, desc); |
| 67 public void evaluate() throws Throwable { | 71 } |
| 68 setUpContentView(); | 72 |
| 69 base.evaluate(); | 73 @Override |
| 70 } | 74 public JavaBridgeActivityTestRule shouldSetUp(boolean runSetUp) { |
| 71 }, desc); | 75 mSetup = runSetUp; |
| 76 return this; |
| 77 } |
| 78 |
| 79 @Override |
| 80 public void setUp() { |
| 81 setUpContentView(); |
| 72 } | 82 } |
| 73 } | 83 } |
| OLD | NEW |