Skip to content

Commit 7417ee0

Browse files
authored
Create a GDT test app for generating events (#3775)
* Create a GDT test app for generating events * Add monkey tests and support for tvOS and macOS in the test app app_spec * Comment out tests for now Needs >= cocoapods-1.8.0 * Remove unsupported property
1 parent cd0ca71 commit 7417ee0

File tree

10 files changed

+1300
-2
lines changed

10 files changed

+1300
-2
lines changed

GoogleDataTransport.podspec

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Shared library for iOS SDK data transport needs.
1919
s.osx.deployment_target = '10.11'
2020
s.tvos.deployment_target = '10.0'
2121

22-
# To develop or run the tests, >= 1.6.0 must be installed.
22+
# To develop or run the tests, >= 1.8.0.beta.1 must be installed.
2323
s.cocoapods_version = '>= 1.4.0'
2424

2525
s.static_framework = true
@@ -41,6 +41,20 @@ Shared library for iOS SDK data transport needs.
4141

4242
common_test_sources = ['GoogleDataTransport/GDTCORTests/Common/**/*.{h,m}']
4343

44+
# Test app specs
45+
s.app_spec 'TestApp' do |app_spec|
46+
app_spec.source_files = 'GoogleDataTransport/GDTTestApp/*.swift'
47+
app_spec.ios.resources = ['GoogleDataTransport/GDTTestApp/ios/*.storyboard']
48+
app_spec.macos.resources = ['GoogleDataTransport/GDTTestApp/macos/*.storyboard']
49+
app_spec.tvos.resources = ['GoogleDataTransport/GDTTestApp/tvos/*.storyboard']
50+
# TODO(mikehaney24): Uncomment when travis is running >= cocoapods-1.8.0
51+
#app_spec.info_plist = {
52+
# 'UILaunchStoryboardName' => 'Main',
53+
# 'UIMainStoryboardFile' => 'Main',
54+
# 'NSMainStoryboardFile' => 'Main'
55+
#}
56+
end
57+
4458
# Unit test specs
4559
s.test_spec 'Tests-Unit' do |test_spec|
4660
test_spec.requires_app_host = false
@@ -61,4 +75,16 @@ Shared library for iOS SDK data transport needs.
6175
test_spec.pod_target_xcconfig = header_search_paths
6276
test_spec.dependency 'GCDWebServer'
6377
end
78+
79+
# Monkey test specs TODO(mikehaney24): Uncomment when travis is running >= cocoapods-1.8.0
80+
# s.test_spec 'Tests-Monkey' do |test_spec|
81+
# test_spec.requires_app_host = true
82+
# test_spec.app_host_name = 'GoogleDataTransport/TestApp'
83+
# test_spec.dependency 'GoogleDataTransport/TestApp'
84+
# test_spec.source_files = ['GoogleDataTransport/GDTTests/Monkey/**/*.{swift}']
85+
# test_spec.info_plist = {
86+
# 'GDT_MONKEYTEST' => '1'
87+
# }
88+
# end
89+
6490
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import GoogleDataTransport
18+
19+
// iOS and tvOS specifics.
20+
#if os(iOS) || os(tvOS)
21+
import UIKit
22+
23+
@UIApplicationMain
24+
class AppDelegate: UIResponder, UIApplicationDelegate {
25+
var window: UIWindow?
26+
27+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
28+
return true
29+
}
30+
}
31+
32+
public class ViewController: UIViewController {
33+
let transport: GDTTransport = GDTTransport(mappingID: "1234", transformers: nil, target: GDTTarget.test.rawValue)
34+
}
35+
36+
// macOS specifics.
37+
#elseif os(macOS)
38+
import Cocoa
39+
40+
@NSApplicationMain class Main: NSObject, NSApplicationDelegate {
41+
var windowController: NSWindowController!
42+
43+
func applicationDidFinishLaunching(aNotification: NSNotification) {}
44+
}
45+
46+
public class ViewController: NSViewController {
47+
let transport: GDTTransport = GDTTransport(mappingID: "1234", transformers: nil, target: GDTTarget.test.rawValue)
48+
}
49+
#endif
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import GoogleDataTransport
18+
19+
// For use by GDT.
20+
class TestDataObject: NSObject, GDTEventDataObject {
21+
func transportBytes() -> Data {
22+
return "Normally, some SDK's data object would populate this. \(Date())".data(using: String.Encoding.utf8)!
23+
}
24+
}
25+
26+
class TestPrioritizer: NSObject, GDTPrioritizer {
27+
func prioritizeEvent(_ event: GDTStoredEvent) {}
28+
29+
func uploadPackage(with conditions: GDTUploadConditions) -> GDTUploadPackage {
30+
return GDTUploadPackage(target: GDTTarget.test)
31+
}
32+
}
33+
34+
class TestUploader: NSObject, GDTUploader {
35+
func readyToUpload(with conditions: GDTUploadConditions) -> Bool {
36+
return false
37+
}
38+
39+
func uploadPackage(_ package: GDTUploadPackage) {}
40+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import Foundation
18+
19+
public struct Globals {
20+
public static var SharedViewController: ViewController?
21+
22+
public static let MonkeyTestLength: TimeInterval = 20.0
23+
24+
public static let MonkeyTestLengthPlusBuffer: TimeInterval = MonkeyTestLength + 10.0
25+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController storyboardIdentifier="MainViewController" id="BYZ-38-t0r" customClass="ViewController" customModule="GoogleDataTransport_iOS_TestApp" customModuleProvider="target" sceneMemberID="viewController">
16+
<layoutGuides>
17+
<viewControllerLayoutGuide type="top" id="g2S-RU-pP8"/>
18+
<viewControllerLayoutGuide type="bottom" id="adO-yW-BBx"/>
19+
</layoutGuides>
20+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
22+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<subviews>
24+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="674-uo-mtw">
25+
<rect key="frame" x="20" y="74" width="555" height="55"/>
26+
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
27+
<constraints>
28+
<constraint firstAttribute="height" constant="55" id="xfr-R6-SiR"/>
29+
</constraints>
30+
<state key="normal" title="Generate data event">
31+
<color key="titleShadowColor" cocoaTouchSystemColor="darkTextColor"/>
32+
</state>
33+
<connections>
34+
<action selector="generateDataEventWithSender:" destination="BYZ-38-t0r" eventType="touchUpInside" id="iph-QW-BXy"/>
35+
</connections>
36+
</button>
37+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FD9-Mn-in7">
38+
<rect key="frame" x="20" y="137" width="555" height="55"/>
39+
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
40+
<constraints>
41+
<constraint firstAttribute="height" constant="55" id="0Uy-Mh-vns"/>
42+
</constraints>
43+
<state key="normal" title="Generate telemetry event">
44+
<color key="titleShadowColor" cocoaTouchSystemColor="darkTextColor"/>
45+
</state>
46+
<connections>
47+
<action selector="generateTelemetryEventWithSender:" destination="BYZ-38-t0r" eventType="touchUpInside" id="rcX-UQ-Br6"/>
48+
</connections>
49+
</button>
50+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IFu-Rf-wNA">
51+
<rect key="frame" x="20" y="200" width="555" height="55"/>
52+
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
53+
<constraints>
54+
<constraint firstAttribute="height" constant="55" id="SQB-HZ-Idj"/>
55+
</constraints>
56+
<state key="normal" title="Generate high priority event (force uploads)">
57+
<color key="titleShadowColor" cocoaTouchSystemColor="darkTextColor"/>
58+
</state>
59+
<connections>
60+
<action selector="generateHighPriorityEventWithSender:" destination="BYZ-38-t0r" eventType="touchUpInside" id="yWd-rX-cMS"/>
61+
</connections>
62+
</button>
63+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yTs-B1-Yoh">
64+
<rect key="frame" x="20" y="263" width="555" height="55"/>
65+
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
66+
<constraints>
67+
<constraint firstAttribute="height" constant="55" id="GCn-oJ-52K"/>
68+
</constraints>
69+
<state key="normal" title="Generate wifi only event">
70+
<color key="titleShadowColor" cocoaTouchSystemColor="darkTextColor"/>
71+
</state>
72+
<connections>
73+
<action selector="generateWifiOnlyEventWithSender:" destination="BYZ-38-t0r" eventType="touchUpInside" id="wo7-Wu-4YZ"/>
74+
</connections>
75+
</button>
76+
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GoogleDataTransport Test App" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L83-mC-jNW">
77+
<rect key="frame" x="20" y="28" width="236" height="21"/>
78+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
79+
<nil key="textColor"/>
80+
<nil key="highlightedColor"/>
81+
</label>
82+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QpN-cI-JZa">
83+
<rect key="frame" x="20" y="326" width="555" height="55"/>
84+
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
85+
<constraints>
86+
<constraint firstAttribute="height" constant="55" id="U3o-sp-jte"/>
87+
</constraints>
88+
<state key="normal" title="Generate daily event">
89+
<color key="titleShadowColor" cocoaTouchSystemColor="darkTextColor"/>
90+
</state>
91+
<connections>
92+
<action selector="generateDailyEventWithSender:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Rfm-OO-P8A"/>
93+
</connections>
94+
</button>
95+
</subviews>
96+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
97+
<constraints>
98+
<constraint firstItem="FD9-Mn-in7" firstAttribute="trailing" secondItem="674-uo-mtw" secondAttribute="trailing" id="6RX-nn-nw3"/>
99+
<constraint firstItem="FD9-Mn-in7" firstAttribute="leading" secondItem="674-uo-mtw" secondAttribute="leading" id="6rB-CC-4ri"/>
100+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="top" secondItem="FD9-Mn-in7" secondAttribute="bottom" constant="8" symbolic="YES" id="7RB-tf-h86"/>
101+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="trailing" secondItem="yTs-B1-Yoh" secondAttribute="trailing" id="AHV-Z5-4pD"/>
102+
<constraint firstItem="QpN-cI-JZa" firstAttribute="top" secondItem="yTs-B1-Yoh" secondAttribute="bottom" constant="8" symbolic="YES" id="Avp-Kq-C50"/>
103+
<constraint firstAttribute="trailingMargin" secondItem="674-uo-mtw" secondAttribute="trailing" constant="5" id="CLj-XH-qp0"/>
104+
<constraint firstItem="L83-mC-jNW" firstAttribute="top" secondItem="g2S-RU-pP8" secondAttribute="bottom" constant="8" symbolic="YES" id="MGc-ef-mcU"/>
105+
<constraint firstItem="FD9-Mn-in7" firstAttribute="top" secondItem="674-uo-mtw" secondAttribute="bottom" constant="8" symbolic="YES" id="T75-Vp-mDG"/>
106+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="trailing" secondItem="FD9-Mn-in7" secondAttribute="trailing" id="XRG-od-G3K"/>
107+
<constraint firstItem="L83-mC-jNW" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="YGK-Ok-Ln6"/>
108+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="leading" secondItem="QpN-cI-JZa" secondAttribute="leading" id="Z6v-fK-gfp"/>
109+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="trailing" secondItem="QpN-cI-JZa" secondAttribute="trailing" id="aT5-1f-Iyb"/>
110+
<constraint firstItem="yTs-B1-Yoh" firstAttribute="top" secondItem="IFu-Rf-wNA" secondAttribute="bottom" constant="8" symbolic="YES" id="iIw-E4-lhu"/>
111+
<constraint firstItem="674-uo-mtw" firstAttribute="leading" secondItem="L83-mC-jNW" secondAttribute="leading" id="kgc-t5-b1V"/>
112+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="leading" secondItem="FD9-Mn-in7" secondAttribute="leading" id="mmu-pQ-Cow"/>
113+
<constraint firstItem="IFu-Rf-wNA" firstAttribute="leading" secondItem="yTs-B1-Yoh" secondAttribute="leading" id="pIF-9S-nhH"/>
114+
<constraint firstItem="674-uo-mtw" firstAttribute="top" secondItem="L83-mC-jNW" secondAttribute="bottom" constant="25" id="rtd-Ze-Yyd"/>
115+
</constraints>
116+
</view>
117+
</viewController>
118+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
119+
</objects>
120+
<point key="canvasLocation" x="134.78260869565219" y="135.9375"/>
121+
</scene>
122+
</scenes>
123+
</document>

0 commit comments

Comments
 (0)