| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.LargeTest; | 7 import android.test.suitebuilder.annotation.LargeTest; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 assertEquals(expectedContent, callback2.mResponseAsString); | 155 assertEquals(expectedContent, callback2.mResponseAsString); |
| 156 assertEquals("quic/1+spdy/3", callback2.mResponseInfo.getNegotiatedProto
col()); | 156 assertEquals("quic/1+spdy/3", callback2.mResponseInfo.getNegotiatedProto
col()); |
| 157 // The total received bytes should be larger than the content length, to
account for | 157 // The total received bytes should be larger than the content length, to
account for |
| 158 // headers. | 158 // headers. |
| 159 assertTrue(callback2.mResponseInfo.getReceivedBytesCount() > expectedCon
tent.length()); | 159 assertTrue(callback2.mResponseInfo.getReceivedBytesCount() > expectedCon
tent.length()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Returns whether a file contains a particular string. | 162 // Returns whether a file contains a particular string. |
| 163 @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE") | 163 @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE") |
| 164 private boolean fileContainsString(String filename, String content) throws I
OException { | 164 private boolean fileContainsString(String filename, String content) throws I
OException { |
| 165 File file = new File(CronetTestFramework.getTestStorage(getContext()) +
"/" + filename); | 165 File file = |
| 166 new File(CronetTestFramework.getTestStorage(getContext()) + "/pr
efs/" + filename); |
| 166 FileInputStream fileInputStream = new FileInputStream(file); | 167 FileInputStream fileInputStream = new FileInputStream(file); |
| 167 byte[] data = new byte[(int) file.length()]; | 168 byte[] data = new byte[(int) file.length()]; |
| 168 fileInputStream.read(data); | 169 fileInputStream.read(data); |
| 169 fileInputStream.close(); | 170 fileInputStream.close(); |
| 170 return new String(data, "UTF-8").contains(content); | 171 return new String(data, "UTF-8").contains(content); |
| 171 } | 172 } |
| 172 } | 173 } |
| OLD | NEW |