Chromium Code Reviews| Index: components/cronet/ios/test/cronet_netlog_test.mm |
| diff --git a/components/cronet/ios/test/cronet_netlog_test.mm b/components/cronet/ios/test/cronet_netlog_test.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a2b7476f368362617b0a80efbcba480f1a6f1541 |
| --- /dev/null |
| +++ b/components/cronet/ios/test/cronet_netlog_test.mm |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <Cronet/Cronet.h> |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "base/logging.h" |
|
mef
2016/11/17 15:58:48
IWYU - remove unused includes.
lilyhoughton
2016/11/22 20:48:42
Done.
|
| +#include "base/mac/scoped_nsobject.h" |
| +#include "base/strings/sys_string_conversions.h" |
| +#include "components/cronet/ios/test/quic_test_server.h" |
| +#include "components/cronet/ios/test/test_server.h" |
| +#include "net/base/mac/url_conversions.h" |
| +#include "net/base/net_errors.h" |
| +#include "net/cert/mock_cert_verifier.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/gtest_mac.h" |
| +#include "url/gurl.h" |
| + |
| +namespace cronet { |
| + |
| +void StartCronetIfNecessary(); |
| + |
| +class NetLogTest : public ::testing::Test { |
| + protected: |
| + NetLogTest() {} |
| + ~NetLogTest() override {} |
| + |
| + void SetUp() override { StartCronetIfNecessary(); } |
| +}; |
| + |
| +TEST(NetLogTest, OpenFile) { |
| + bool netlog_started = |
| + [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; |
| + [Cronet stopNetLog]; |
| + |
| + EXPECT_TRUE(netlog_started); |
|
kapishnikov
2016/11/18 22:17:27
Can we check that the file was created? The file n
lilyhoughton
2016/12/02 16:30:07
Done.
|
| +} |
| + |
| +TEST(NetLogTest, NonExistantDir) { |
| + NSString* notdir = [[[NSProcessInfo processInfo] globallyUniqueString] |
| + stringByAppendingString:@"/netlog.json"]; |
| + bool netlog_started = [Cronet startNetLogToFile:notdir logBytes:NO]; |
| + |
| + EXPECT_FALSE(netlog_started); |
| +} |
| + |
| +TEST(NetLogTest, EmptyFilename) { |
| + bool netlog_started = [Cronet startNetLogToFile:@"" logBytes:NO]; |
| + |
| + EXPECT_FALSE(netlog_started); |
| +} |
| +} |