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

Side by Side Diff: components/cronet/ios/test/cronet_netlog_test.mm

Issue 2465303002: [cronet] make startNetLogToFile write to correct file (Closed)
Patch Set: Sync Created 4 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <Cronet/Cronet.h>
6 #import <Foundation/Foundation.h>
7
8 #include "base/logging.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h"
11 #include "components/cronet/ios/test/test_server.h"
12 #include "net/base/mac/url_conversions.h"
13 #include "net/base/net_errors.h"
14 #include "net/cert/mock_cert_verifier.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/gtest_mac.h"
17 #include "url/gurl.h"
18
19 namespace cronet {
20
21 void StartCronetIfNecessary();
22
23 class NetLogTest : public ::testing::Test {
24 protected:
25 NetLogTest() {}
26 ~NetLogTest() override {}
27
28 void SetUp() override { StartCronetIfNecessary(); }
29 };
30
31 TEST(NetLogTest, OpenFile) {
32 bool netlog_started =
33 [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES];
mef 2016/12/09 18:30:41 this may behave differently during first and conse
lilyhoughton 2016/12/09 19:42:50 Not sure how to account for that besides just havi
34 [Cronet stopNetLog];
35
36 EXPECT_TRUE(netlog_started);
37 }
38
39 TEST(NetLogTest, CreateFile) {
40 NSString* filename = [[[NSProcessInfo processInfo] globallyUniqueString]
41 stringByAppendingString:@"_netlog.json"];
42 bool netlog_started = [Cronet startNetLogToFile:filename logBytes:YES];
43 [Cronet stopNetLog];
44
45 bool file_created = [[NSFileManager defaultManager]
46 fileExistsAtPath:[Cronet netLogPath:filename]];
47
48 EXPECT_TRUE(netlog_started);
49 EXPECT_TRUE(file_created);
mef 2016/12/09 18:30:41 Delete that [Cronet netLogPath:filename] at the en
lilyhoughton 2016/12/09 19:42:50 Done.
50 }
51
52 TEST(NetLogTest, NonExistantDir) {
mef 2016/12/09 18:30:41 Add test for creating netlog in existing directory
lilyhoughton 2016/12/09 19:42:50 Done.
53 NSString* notdir = [[[NSProcessInfo processInfo] globallyUniqueString]
54 stringByAppendingString:@"/netlog.json"];
55 bool netlog_started = [Cronet startNetLogToFile:notdir logBytes:NO];
56
57 EXPECT_FALSE(netlog_started);
58 }
59
60 TEST(NetLogTest, EmptyFilename) {
mef 2016/12/09 18:30:41 Add test for passing absolute path name.
lilyhoughton 2016/12/09 19:42:50 Added a check to startNetLogToFile just to make su
61 bool netlog_started = [Cronet startNetLogToFile:@"" logBytes:NO];
62
63 EXPECT_FALSE(netlog_started);
64 }
65 }
OLDNEW
« components/cronet/ios/cronet_environment.mm ('K') | « components/cronet/ios/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698