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

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 3 years, 11 months 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
« no previous file with comments | « components/cronet/ios/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h"
9
10 namespace cronet {
11
12 void StartCronetIfNecessary();
13
14 class NetLogTest : public ::testing::Test {
15 protected:
16 NetLogTest() {}
17 ~NetLogTest() override {}
18
19 void SetUp() override { StartCronetIfNecessary(); }
20 };
21
22 TEST(NetLogTest, OpenFile) {
23 bool netlog_started =
24 [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES];
25 [Cronet stopNetLog];
26
27 EXPECT_TRUE(netlog_started);
28 }
29
30 TEST(NetLogTest, CreateFile) {
31 NSString* filename = [[[NSProcessInfo processInfo] globallyUniqueString]
32 stringByAppendingString:@"_netlog.json"];
33 bool netlog_started = [Cronet startNetLogToFile:filename logBytes:YES];
34 [Cronet stopNetLog];
35
36 bool file_created = [[NSFileManager defaultManager]
37 fileExistsAtPath:[Cronet getNetLogPathForFile:filename]];
38
39 [[NSFileManager defaultManager]
40 removeItemAtPath:[Cronet getNetLogPathForFile:filename]
41 error:nil];
42
43 EXPECT_TRUE(netlog_started);
44 EXPECT_TRUE(file_created);
45 }
46
47 TEST(NetLogTest, NonExistantDir) {
48 NSString* notdir = [[[NSProcessInfo processInfo] globallyUniqueString]
49 stringByAppendingString:@"/netlog.json"];
50 bool netlog_started = [Cronet startNetLogToFile:notdir logBytes:NO];
51
52 EXPECT_FALSE(netlog_started);
53 }
54
55 TEST(NetLogTest, ExistantDir) {
56 NSString* dir = [[NSProcessInfo processInfo] globallyUniqueString];
57
58 bool dir_created = [[NSFileManager defaultManager]
59 createDirectoryAtPath:[Cronet getNetLogPathForFile:dir]
60 withIntermediateDirectories:NO
61 attributes:nil
62 error:nil];
63
64 bool netlog_started =
65 [Cronet startNetLogToFile:[dir stringByAppendingString:@"/netlog.json"]
66 logBytes:NO];
67
68 [[NSFileManager defaultManager]
69 removeItemAtPath:[Cronet
70 getNetLogPathForFile:
71 [dir stringByAppendingString:@"/netlog.json"]]
72 error:nil];
73
74 [[NSFileManager defaultManager]
75 removeItemAtPath:[Cronet getNetLogPathForFile:dir]
76 error:nil];
77
78 EXPECT_TRUE(dir_created);
79 EXPECT_TRUE(netlog_started);
80 }
81
82 TEST(NetLogTest, EmptyFilename) {
83 bool netlog_started = [Cronet startNetLogToFile:@"" logBytes:NO];
84
85 EXPECT_FALSE(netlog_started);
86 }
87
88 TEST(NetLogTest, AbsoluteFilename) {
89 bool netlog_started =
90 [Cronet startNetLogToFile:@"/home/netlog.json" logBytes:NO];
91
92 EXPECT_FALSE(netlog_started);
93 }
94 }
OLDNEW
« no previous file with comments | « components/cronet/ios/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698