Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java

Issue 2770393002: Add setup action interface (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.SetUpTestRule;
10 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; 11 import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
11 import org.chromium.content_shell_apk.ContentShellActivity; 12 import org.chromium.content_shell_apk.ContentShellActivity;
12 import org.chromium.content_shell_apk.ContentShellActivityTestRule; 13 import org.chromium.content_shell_apk.ContentShellActivityTestRule;
13 import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback; 14 import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback;
14 15
15 import java.lang.annotation.Annotation; 16 import java.lang.annotation.Annotation;
16 17
17 /** 18 /**
18 * ActivityTestRule with common functionality for testing the Java Bridge. 19 * ActivityTestRule with common functionality for testing the Java Bridge.
19 */ 20 */
20 public class JavaBridgeActivityTestRule 21 public class JavaBridgeActivityTestRule
21 extends ContentShellActivityTestRule implements TestCommonCallback<Conte ntShellActivity> { 22 extends ContentShellActivityTestRule implements TestCommonCallback<Conte ntShellActivity>,
22 private JavaBridgeTestCommon mTestCommon; 23 SetUpTestRule<JavaBridge ActivityTestRule> {
23 24 private JavaBridgeTestCommon mTestCommon = new JavaBridgeTestCommon(this);
24 public JavaBridgeActivityTestRule() { 25 private boolean mRunSetUp = false;
25 super();
26 mTestCommon = new JavaBridgeTestCommon(this);
27 }
28 26
29 /** 27 /**
30 * Sets up the ContentView. Intended to be called from setUp(). 28 * Sets up the ContentView. Intended to be called from setUp().
31 */ 29 */
32 private void setUpContentView() { 30 private void setUpContentView() {
33 mTestCommon.setUpContentView(); 31 mTestCommon.setUpContentView();
34 } 32 }
35 33
36 public TestCallbackHelperContainer getTestCallBackHelperContainer() { 34 public TestCallbackHelperContainer getTestCallBackHelperContainer() {
37 return mTestCommon.getTestCallBackHelperContainer(); 35 return mTestCommon.getTestCallBackHelperContainer();
(...skipping 17 matching lines...) Expand all
55 final Class<? extends Annotation> requiredAnnotation) throws Excepti on { 53 final Class<? extends Annotation> requiredAnnotation) throws Excepti on {
56 mTestCommon.injectObjectsAndReload(object1, name1, object2, name2, requi redAnnotation); 54 mTestCommon.injectObjectsAndReload(object1, name1, object2, name2, requi redAnnotation);
57 } 55 }
58 56
59 public void synchronousPageReload() throws Throwable { 57 public void synchronousPageReload() throws Throwable {
60 mTestCommon.synchronousPageReload(); 58 mTestCommon.synchronousPageReload();
61 } 59 }
62 60
63 @Override 61 @Override
64 public Statement apply(final Statement base, Description desc) { 62 public Statement apply(final Statement base, Description desc) {
65 return super.apply(new Statement() { 63 return super.apply(new SetUpStatement(base, this, mRunSetUp), desc);
mikecase (-- gone --) 2017/03/27 18:40:59 guessing this needs to be SetUpTestRule.SetUpState
the real yoland 2017/03/27 20:52:36 Done
66 @Override 64 }
67 public void evaluate() throws Throwable { 65
68 setUpContentView(); 66 @Override
69 base.evaluate(); 67 public JavaBridgeActivityTestRule shouldSetUp(boolean shouldSetUp) {
70 } 68 mRunSetUp = shouldSetUp;
71 }, desc); 69 return this;
70 }
71
72 @Override
73 public void setUp() {
74 setUpContentView();
72 } 75 }
73 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698