Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMPhobos
Commits
dfe48e19
Commit
dfe48e19
authored
Apr 16, 2019
by
井庆林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改清除缓存机制
parent
89aa4c0a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
13 deletions
+146
-13
project.pbxproj
Example/GMPhobos.xcodeproj/project.pbxproj
+0
-0
GMPhobos-Example.xcscheme
...codeproj/xcshareddata/xcschemes/GMPhobos-Example.xcscheme
+10
-2
GMPhobos_ExampleTests.m
Example/GMPhobos_ExampleTests/GMPhobos_ExampleTests.m
+37
-0
Info.plist
Example/GMPhobos_ExampleTests/Info.plist
+22
-0
Podfile.lock
Example/Podfile.lock
+3
-3
GMPhotoTest.m
Example/Tests/GMPhotoTest.m
+74
-7
Phobos.m
GMPhobos/Classes/Phobos.m
+0
-1
No files found.
Example/GMPhobos.xcodeproj/project.pbxproj
View file @
dfe48e19
This diff is collapsed.
Click to expand it.
Example/GMPhobos.xcodeproj/xcshareddata/xcschemes/GMPhobos-Example.xcscheme
View file @
dfe48e19
...
...
@@ -26,7 +26,6 @@
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
language =
""
shouldUseLaunchSchemeArgsEnv =
"YES"
>
<Testables>
<TestableReference
...
...
@@ -44,6 +43,16 @@
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped =
"NO"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"63EFAB0D22658352005EEAC6"
BuildableName =
"GMPhobos_ExampleTests.xctest"
BlueprintName =
"GMPhobos_ExampleTests"
ReferencedContainer =
"container:GMPhobos.xcodeproj"
>
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
...
...
@@ -61,7 +70,6 @@
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
language =
""
launchStyle =
"0"
useCustomWorkingDirectory =
"NO"
ignoresPersistentStateOnLaunch =
"NO"
...
...
Example/GMPhobos_ExampleTests/GMPhobos_ExampleTests.m
0 → 100644
View file @
dfe48e19
//
// GMPhobos_ExampleTests.m
// GMPhobos_ExampleTests
//
// Created by Jing on 2019/4/16.
// Copyright © 2019 licong. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface
GMPhobos_ExampleTests
:
XCTestCase
@end
@implementation
GMPhobos_ExampleTests
-
(
void
)
setUp
{
// Put setup code here. This method is called before the invocation of each test method in the class.
}
-
(
void
)
tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
-
(
void
)
testExample
{
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
-
(
void
)
testPerformanceExample
{
// This is an example of a performance test case.
[
self
measureBlock
:
^
{
// Put the code you want to measure the time of here.
}];
}
@end
Example/GMPhobos_ExampleTests/Info.plist
0 → 100644
View file @
dfe48e19
<
?xml
v
e
rsion="
1
.
0
"
e
n
c
o
d
ing="UT
F
-
8
"?
>
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
$
(
DEVELOPMENT_LANGUAGE
)<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
string
>
$
(
EXECUTABLE_NAME
)<
/string
>
<
k
e
y
>
CFBundleIdentifier
<
/k
e
y
>
<
string
>
$
(
PRODUCT_BUNDLE_IDENTIFIER
)<
/string
>
<
k
e
y
>
CFBundleInfoDictionaryVersion
<
/k
e
y
>
<
string
>
6.0
<
/string
>
<
k
e
y
>
CFBundleName
<
/k
e
y
>
<
string
>
$
(
PRODUCT_NAME
)<
/string
>
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
BNDL
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.0
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
string
>
1
<
/string
>
<
/
d
i
c
t
>
<
/plist
>
Example/Podfile.lock
View file @
dfe48e19
...
...
@@ -35,7 +35,7 @@ PODS:
- GMKit/Protocol (0.8.4):
- Masonry (= 1.1.0)
- SDWebImage (= 3.7.6)
- GMPhobos (1.
0.7
):
- GMPhobos (1.
1.2
):
- GMCache (= 0.2.3)
- GMKit
- Masonry (1.1.0)
...
...
@@ -63,11 +63,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: 09a3029c96fe130e3a21faef70b3d9d2ce92d639
GMKit: a30da06b84e5c4a357d427c70d1b5ec672a1f6a1
GMPhobos:
dd0026c837b0909013a9002b7f3e04f28786e24b
GMPhobos:
5d9b29fb16fb7b8f3b2983aaab8b42cefc510baa
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: ea0fac2144ac80baf8f21576cde49526c19991ad
COCOAPODS: 1.6.
0.beta.2
COCOAPODS: 1.6.
1
Example/Tests/GMPhotoTest.m
View file @
dfe48e19
...
...
@@ -33,7 +33,7 @@ NSString *const MockCityId = @"beijing";
-
(
void
)
tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[
super
tearDown
];
[
GMCache
removeObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
[
GMCache
removeObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
}
/**
...
...
@@ -45,7 +45,7 @@ NSString *const MockCityId = @"beijing";
[
_client
setUserId
:
MockUserId
];
[
_client
setCurrentCityId
:
MockCityId
];
[
Phobos
track
:
MockEventId
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
1
,
@"array is empty"
);
NSDictionary
*
dict
=
[
array
objectAtIndex
:
0
];
[
self
verfiyDict
:
dict
];
...
...
@@ -59,7 +59,7 @@ NSString *const MockCityId = @"beijing";
*/
-
(
void
)
testTrackEventWithoutAttr
{
[
Phobos
track
:
MockEventId
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
1
,
@"array is empty"
);
NSDictionary
*
dict
=
[
array
objectAtIndex
:
0
];
[
self
verfiyDict
:
dict
];
...
...
@@ -74,7 +74,7 @@ NSString *const MockCityId = @"beijing";
-
(
void
)
testTrackEventWithAttr
{
NSDictionary
*
attr
=
@{
@"attr"
:
@"track_attr"
};
[
Phobos
track
:
MockEventId
attributes
:
attr
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
1
,
@"array is empty"
);
NSDictionary
*
dict
=
[
array
objectAtIndex
:
0
];
[
self
verfiyDict
:
dict
];
...
...
@@ -95,10 +95,77 @@ NSString *const MockCityId = @"beijing";
// When
[
Phobos
track
:
MockEventId
attributes
:
attr
sendNow
:
YES
];
// Then
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
0
,
@"array should be empty"
);
}
/**
* @brief 测试立即发送带参数事件成功,不应该清除不立即发送的埋点
*
* @since 1.1.4
*/
-
(
void
)
testTrackEventWithAttrAndSendNowDonotClearNormal
{
// Given
NSDictionary
*
attr
=
@{
@"attr"
:
@"track_attr"
};
// When
[
Phobos
track
:
MockEventId
attributes
:
attr
sendNow
:
NO
];
// When
[
Phobos
track
:
MockEventId
attributes
:
attr
sendNow
:
YES
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
!=
0
,
@"array shouldn't be empty"
);
}
/**
* @brief 测试二次立即发送带参数事件成功,不应该重复发送上一条
*
* @since 1.1.4
*/
-
(
void
)
testTrackEventWithDoubleAttrAndSendNow
{
// Given
NSDictionary
*
attr
=
@{
@"attr"
:
@"track_attr"
};
// When
[
Phobos
track
:
MockEventId
attributes
:
attr
sendNow
:
YES
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosTempCacheKey
];
XCTAssertTrue
(
array
.
count
==
0
,
@"array shouldn't be empty"
);
// When
[
Phobos
track
:
MockEventId
attributes
:
attr
sendNow
:
YES
];
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosTempCacheKey
];
XCTAssertTrue
(
array
.
count
==
0
,
@"array shouldn't be empty"
);
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
0
,
@"array shouldn't be empty"
);
}
/**
* @brief 测试不立即发送带参数事件成功后,数据会被清除
*
* @since 1.1.4
*/
-
(
void
)
testTrackEventWithDoubleAttrAndNoSendNow
{
// remove 保证PhobosCacheKey起始数据为空
[
GMCache
removeObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
NSDictionary
*
attr
=
@{
@"attr"
:
@"track_attr"
};
//
[
Phobos
track
:
MockEventId
attributes
:
attr
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
1
,
@"array shouldn't be empty"
);
// PhobosCacheKey超过50条数据会自动上报,模拟此情况
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
[
Phobos
track
:
MockEventId
attributes
:
attr
];
}
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
0
,
@"array shouldn't be empty"
);
[
Phobos
track
:
MockEventId
attributes
:
attr
];
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
==
1
,
@"array shouldn't be empty"
);
}
-
(
void
)
verfiyDict
:
(
NSDictionary
*
)
dict
{
NSArray
*
keys
=
[
dict
allKeys
];
XCTAssertTrue
([
keys
containsObject
:
@"type"
],
@"Missing type"
);
...
...
@@ -139,7 +206,7 @@ NSString *const MockCityId = @"beijing";
[
controller
viewWillAppear
:
true
];
[
controller
viewWillDisappear
:
true
];
[
self
paramUnNilCheck
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
!=
0
,
@"PhobosCacheKey 下面应该有数据"
);
NSDictionary
*
dic
=
array
[
0
][
@"params"
];
...
...
@@ -153,7 +220,7 @@ NSString *const MockCityId = @"beijing";
}
-
(
void
)
paramUnNilCheck
{
NSArray
*
array
=
[
GMCache
fetchObjectAtD
uc
mentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtD
ocu
mentPathWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
!=
0
,
@"PhobosCacheKey 下面应该有数据"
);
NSDictionary
*
dic
=
array
[
0
][
@"params"
];
...
...
GMPhobos/Classes/Phobos.m
View file @
dfe48e19
...
...
@@ -565,7 +565,6 @@ static NSString *sdkVersion = @"110";
//2.把缓存区的数据发送给服务器
[
self
sendArray
];
//3.把原有的数据删除
[
GMCache
removeObjectAtDocumentPathWithkey
:
PhobosTempCacheKey
];
if
(
clean
)
{
[
GMCache
removeObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment