1 package com.atlassian.webdriver.testing.rule;
2
3 import com.google.inject.Inject;
4 import org.junit.rules.RuleChain;
5 import org.junit.rules.TestRule;
6 import org.junit.runner.Description;
7 import org.junit.runners.model.Statement;
8
9
10
11
12
13
14
15
16 public final class DefaultProductContextRules
17 {
18 private DefaultProductContextRules()
19 {
20 throw new AssertionError("Don't instantiate me");
21 }
22
23 public final static class ForClass implements TestRule
24 {
25 private final RuleChain chain;
26
27 @Inject
28 public ForClass(DriverCleanupRule driverCleanupRule)
29 {
30 this.chain = RuleChain.outerRule(driverCleanupRule);
31 }
32
33 @Override
34 public Statement apply(Statement base, Description description)
35 {
36 return chain.apply(base, description);
37 }
38 }
39
40 public final static class ForMethod implements TestRule
41 {
42 private final RuleChain chain;
43
44 @Inject
45 public ForMethod(IgnoreBrowserRule ignoreBrowserRule, LogPageSourceRule logPageSourceRule,
46 SessionCleanupRule sessionCleanupRule, WebDriverScreenshotRule webDriverScreenshotRule,
47 WindowSizeRule windowSizeRule)
48 {
49 this.chain = RuleChain.outerRule(ignoreBrowserRule)
50 .around(sessionCleanupRule)
51 .around(windowSizeRule)
52 .around(webDriverScreenshotRule)
53 .around(logPageSourceRule);
54 }
55
56 @Override
57 public Statement apply(Statement base, Description description)
58 {
59 return chain.apply(base, description);
60 }
61 }
62
63 }