Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: adblock-android-tests/src/org/adblockplus/libadblockplus/tests/MockWebRequestTest.java

Issue 29819555: Fix libadblockplus-android tests
Left Patch Set: Created July 1, 2018, 9:20 p.m.
Right Patch Set: Fixed indentation issues. Created Aug. 27, 2018, 8:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 "_webRequest.GET('http://example.com/', {}, null)", 70 "_webRequest.GET('http://example.com/', {}, null)",
71 "_webRequest.GET('http://example.com/', {}, function(){}, 0)" 71 "_webRequest.GET('http://example.com/', {}, function(){}, 0)"
72 }; 72 };
73 73
74 for (String source : sources) 74 for (String source : sources)
75 { 75 {
76 try 76 try
77 { 77 {
78 jsEngine.evaluate(source); 78 jsEngine.evaluate(source);
79 fail(source); 79 fail(source);
80 } catch (AdblockPlusException e) 80 }
81 catch (AdblockPlusException e)
81 { 82 {
82 // ignored 83 // ignored
83 } 84 }
84 } 85 }
85 } 86 }
86 87
87 @Test 88 @Test
88 public void testSuccessfulRequest() 89 public void testSuccessfulRequest()
89 { 90 {
90 jsEngine.evaluate( 91 jsEngine.evaluate(
91 "let foo = true; _webRequest.GET('http://example.com/', {X: 'Y'}, function (result) {foo = result;} )"); 92 "let foo = true; _webRequest.GET('http://example.com/', {X: 'Y'}, function (result) {foo = result;} )");
92 assertTrue(jsEngine.evaluate("foo").isBoolean()); 93 assertTrue(jsEngine.evaluate("foo").isBoolean());
93 assertTrue(jsEngine.evaluate("foo").asBoolean()); 94 assertTrue(jsEngine.evaluate("foo").asBoolean());
94 95
95 SystemClock.sleep(200); 96 SystemClock.sleep(200);
96 97
97 assertEquals( 98 assertEquals(
98 ServerResponse.NsStatus.OK.getStatusCode(), 99 ServerResponse.NsStatus.OK.getStatusCode(),
99 jsEngine.evaluate("foo.status").asLong()); 100 jsEngine.evaluate("foo.status").asLong());
100 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex t").asString()); 101 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex t").asString());
101 assertEquals("{\"Foo\":\"Bar\"}", 102 assertEquals("{\"Foo\":\"Bar\"}",
102 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString()); 103 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString());
103 } 104 }
104 } 105 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld