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

Side by Side Diff: testing/android/junit/java/src/org/chromium/testing/local/AnnotationProcessor.java

Issue 2722243002: 📰 Add tests for Tile and TileGroup (Closed)
Patch Set: Revert default Rule effect Created 3 years, 9 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
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.testing.local; 5 package org.chromium.testing.local;
6 6
7 import org.junit.rules.ExternalResource; 7 import org.junit.rules.ExternalResource;
8 import org.junit.runner.Description; 8 import org.junit.runner.Description;
9 import org.junit.runners.model.Statement; 9 import org.junit.runners.model.Statement;
10 10
(...skipping 29 matching lines...) Expand all
40 private Description mTestDescription; 40 private Description mTestDescription;
41 private T mAnnotation; 41 private T mAnnotation;
42 42
43 public AnnotationProcessor(Class<T> annotationClass) { 43 public AnnotationProcessor(Class<T> annotationClass) {
44 mAnnotationClass = annotationClass; 44 mAnnotationClass = annotationClass;
45 } 45 }
46 46
47 @Override 47 @Override
48 public Statement apply(Statement base, Description description) { 48 public Statement apply(Statement base, Description description) {
49 mTestDescription = description; 49 mTestDescription = description;
50 mAnnotation = description.getAnnotation(mAnnotationClass); 50 mAnnotation = getAnnotation(description);
51 if (mAnnotation == null) return base; 51 if (mAnnotation == null) return base;
52 52
53 // Return the wrapped statement to execute before() and after(). 53 // Return the wrapped statement to execute before() and after().
54 return super.apply(base, description); 54 return super.apply(base, description);
55 } 55 }
56 56
57 /** @return {@link Description} of the current test. */ 57 /** @return {@link Description} of the current test. */
58 protected Description getTestDescription() { 58 protected Description getTestDescription() {
59 return mTestDescription; 59 return mTestDescription;
60 } 60 }
61 61
62 /** @return the annotation that caused the test to be processed. */ 62 /** @return the annotation that caused the test to be processed. */
63 protected T getAnnotation() { 63 protected T getAnnotation() {
64 return mAnnotation; 64 return mAnnotation;
65 } 65 }
66
67 private T getAnnotation(Description description) {
68 T annotation = description.getAnnotation(mAnnotationClass);
69 if (annotation != null) return annotation;
70
71 annotation = description.getTestClass().getAnnotation(mAnnotationClass);
72 return annotation;
73 }
66 } 74 }
OLDNEW
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698