merges default Experimental-decrease_disk_IO
authorbuff <andreas@pep-project.org>
Wed, 16 Jan 2019 14:18:47 +0100
branchExperimental-decrease_disk_IO
changeset 763122f32ee14bdf
parent 7529 dd195d307299
parent 7532 cc03af4dc66d
merges default
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Tue Jan 15 15:32:35 2019 +0100
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Wed Jan 16 14:18:47 2019 +0100
     1.3 @@ -485,6 +485,7 @@
     1.4  		43D070312133DB920013B120 /* AppSettingsProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D070302133DB920013B120 /* AppSettingsProtocol.swift */; };
     1.5  		43D070332133DC500013B120 /* DefaultAppSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D070322133DC500013B120 /* DefaultAppSettings.swift */; };
     1.6  		43D3379021A3F32500E40114 /* ImapUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D3378F21A3F32500E40114 /* ImapUtil.swift */; };
     1.7 +		43D3F8A121EDDF19002D5AFC /* ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt in Resources */ = {isa = PBXBuildFile; fileRef = 43D3F8A021EDDF19002D5AFC /* ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt */; };
     1.8  		43D51E891DD5D902008B77A8 /* SimpleOperationsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D51E881DD5D902008B77A8 /* SimpleOperationsTest.swift */; };
     1.9  		43D755EB1F25D234006F933A /* MatchUidToMsnOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D755EA1F25D234006F933A /* MatchUidToMsnOperation.swift */; };
    1.10  		43D755F61F262B37006F933A /* PantomimeError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D755F51F262B37006F933A /* PantomimeError.swift */; };
    1.11 @@ -559,6 +560,10 @@
    1.12  		49D3BECC20F8F7330043E05D /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D3BECB20F8F7330043E05D /* LoginViewController.swift */; };
    1.13  		49D521541E73E1C20097987B /* MessageModel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49D521531E73E1C20097987B /* MessageModel.framework */; };
    1.14  		49D521551E73E1C20097987B /* MessageModel.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 49D521531E73E1C20097987B /* MessageModel.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
    1.15 +		49DCCD2521E8ABA900ABE487 /* SecurePDFScreenshotTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49A2BC0B21DCE78D00E10C1A /* SecurePDFScreenshotTest.swift */; };
    1.16 +		49DCCD2621E8ABD300ABE487 /* nojavascript.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 49DCCD1F21E75BE300ABE487 /* nojavascript.pdf */; };
    1.17 +		49DCCD2721E8ABD600ABE487 /* javascript.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 49079D9821E3867900D15A0D /* javascript.pdf */; };
    1.18 +		49DCCD2821E8ABDF00ABE487 /* ScreenshotTestUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */; };
    1.19  		5D039A9C1D0EE7F900AD59EC /* PEPUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */; };
    1.20  		5D039AA21D0EEA3700AD59EC /* DecryptMessagesOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039AA11D0EEA3700AD59EC /* DecryptMessagesOperation.swift */; };
    1.21  		5DEBAA481DE59C3B00FAE12C /* NetworkServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DEBAA471DE59C3B00FAE12C /* NetworkServiceTests.swift */; };
    1.22 @@ -1141,6 +1146,7 @@
    1.23  		43D070302133DB920013B120 /* AppSettingsProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsProtocol.swift; sourceTree = "<group>"; };
    1.24  		43D070322133DC500013B120 /* DefaultAppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultAppSettings.swift; sourceTree = "<group>"; };
    1.25  		43D3378F21A3F32500E40114 /* ImapUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImapUtil.swift; sourceTree = "<group>"; };
    1.26 +		43D3F8A021EDDF19002D5AFC /* ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt"; sourceTree = "<group>"; };
    1.27  		43D51E881DD5D902008B77A8 /* SimpleOperationsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleOperationsTest.swift; sourceTree = "<group>"; };
    1.28  		43D755EA1F25D234006F933A /* MatchUidToMsnOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MatchUidToMsnOperation.swift; sourceTree = "<group>"; };
    1.29  		43D755F51F262B37006F933A /* PantomimeError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PantomimeError.swift; sourceTree = "<group>"; };
    1.30 @@ -1193,6 +1199,7 @@
    1.31  		43FE802D209992B800E97AB3 /* QualifyServerIsLocalService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QualifyServerIsLocalService.swift; sourceTree = "<group>"; };
    1.32  		43FE802F209995AD00E97AB3 /* QualifyServerIsLocalServiceTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QualifyServerIsLocalServiceTest.swift; sourceTree = "<group>"; };
    1.33  		4902244E20E50488000E8D7C /* ThreadNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadNavigationDelegate.swift; sourceTree = "<group>"; };
    1.34 +		49079D9821E3867900D15A0D /* javascript.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = javascript.pdf; sourceTree = "<group>"; };
    1.35  		490CEBA62100EAD500E8579C /* SelfDismissable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfDismissable.swift; sourceTree = "<group>"; };
    1.36  		490CEBA821020BF900E8579C /* LoginViewController+Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LoginViewController+Keyboard.swift"; sourceTree = "<group>"; };
    1.37  		491116BC216E0DF4005A42D2 /* MessageViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewModelTests.swift; sourceTree = "<group>"; };
    1.38 @@ -1207,10 +1214,12 @@
    1.39  		495560871E71517F0016579E /* libpEpiOSAdapter.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpEpiOSAdapter.a; path = "../../Library/Developer/Xcode/DerivedData/pEpForiOS-cryqwhejxdsfocdwswvsgjrywqhr/Build/Products/Debug-iphonesimulator/libpEpiOSAdapter.a"; sourceTree = "<group>"; };
    1.40  		495D69BE20DBAEE900986007 /* ThreadViewController+SwipeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ThreadViewController+SwipeCell.swift"; sourceTree = "<group>"; };
    1.41  		495F607B20B564CD00F47BD6 /* EmailViewController+SizeClasses.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailViewController+SizeClasses.swift"; sourceTree = "<group>"; };
    1.42 +		495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenshotTestUtil.swift; sourceTree = "<group>"; };
    1.43  		496355B020ECEA2900AA4387 /* ThreadedEmailViewModel+EmailDisplayDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ThreadedEmailViewModel+EmailDisplayDelegate.swift"; sourceTree = "<group>"; };
    1.44  		49691B1420D7FD0200CA9367 /* MessageViewModelConfigurable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewModelConfigurable.swift; sourceTree = "<group>"; };
    1.45  		496C0EE620BC2A880009B5B9 /* EmailDisplayDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailDisplayDelegate.swift; sourceTree = "<group>"; };
    1.46  		496C0EEA20BC4B360009B5B9 /* EmailListViewModel+EmailDisplayDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailListViewModel+EmailDisplayDelegate.swift"; sourceTree = "<group>"; };
    1.47 +		49A2BC0B21DCE78D00E10C1A /* SecurePDFScreenshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurePDFScreenshotTest.swift; sourceTree = "<group>"; };
    1.48  		49A6114D2179F3A1006BA3C5 /* UnitTestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitTestUtils.swift; sourceTree = "<group>"; };
    1.49  		49C2750020C04DDB0075F6FF /* EmailViewController+DisplayedMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailViewController+DisplayedMessage.swift"; sourceTree = "<group>"; };
    1.50  		49C34AF520E4F649009D11CC /* CellDetailTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CellDetailTransition.swift; sourceTree = "<group>"; };
    1.51 @@ -1218,6 +1227,7 @@
    1.52  		49D3BECB20F8F7330043E05D /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
    1.53  		49D521531E73E1C20097987B /* MessageModel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MessageModel.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    1.54  		49D521561E73E1C70097987B /* ServerConfig.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ServerConfig.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    1.55 +		49DCCD1F21E75BE300ABE487 /* nojavascript.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = nojavascript.pdf; sourceTree = "<group>"; };
    1.56  		5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PEPUtil.swift; sourceTree = "<group>"; };
    1.57  		5D039AA11D0EEA3700AD59EC /* DecryptMessagesOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecryptMessagesOperation.swift; sourceTree = "<group>"; };
    1.58  		5DEBAA471DE59C3B00FAE12C /* NetworkServiceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkServiceTests.swift; sourceTree = "<group>"; };
    1.59 @@ -1392,6 +1402,7 @@
    1.60  				151F71EE202A06750057C74D /* NetworkServiceObserver.swift */,
    1.61  				151F71EC202A06750057C74D /* TestDataBase.swift */,
    1.62  				151F71F5202A06750057C74D /* TestUtil.swift */,
    1.63 +				495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */,
    1.64  				43D3378F21A3F32500E40114 /* ImapUtil.swift */,
    1.65  				49A6114D2179F3A1006BA3C5 /* UnitTestUtils.swift */,
    1.66  				43EC75B22164E97800048CFE /* DecryptionUtil.swift */,
    1.67 @@ -2285,6 +2296,7 @@
    1.68  		43980E3D1CBD0BCA00A7FC3C /* pEpForiOSTests */ = {
    1.69  			isa = PBXGroup;
    1.70  			children = (
    1.71 +				49174CAD21EE408F006DBD63 /* PDF Security Tests */,
    1.72  				43FE802F209995AD00E97AB3 /* QualifyServerIsLocalServiceTest.swift */,
    1.73  				151F71EB202A06750057C74D /* TestUtils */,
    1.74  				43B2C3151D2280ED00A08557 /* Resources */,
    1.75 @@ -2503,6 +2515,7 @@
    1.76  				438F4EE4215FAD0500168B5E /* Harry Bryant iostest002@peptest.ch (0x5716EA2D9AE32468) pub-sec.asc */,
    1.77  				438F4EE0215F9CB300168B5E /* SimplifiedKeyImport_Harry_To_Rick_with_Leon.txt */,
    1.78  				433F2E2921E3581800E1CA49 /* ENGINE-505_Mail_NullInnerMimeType.txt */,
    1.79 +				43D3F8A021EDDF19002D5AFC /* ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt */,
    1.80  			);
    1.81  			path = Resources;
    1.82  			sourceTree = "<group>";
    1.83 @@ -2653,6 +2666,16 @@
    1.84  			path = MessageThreading;
    1.85  			sourceTree = "<group>";
    1.86  		};
    1.87 +		49174CAD21EE408F006DBD63 /* PDF Security Tests */ = {
    1.88 +			isa = PBXGroup;
    1.89 +			children = (
    1.90 +				49A2BC0B21DCE78D00E10C1A /* SecurePDFScreenshotTest.swift */,
    1.91 +				49DCCD1F21E75BE300ABE487 /* nojavascript.pdf */,
    1.92 +				49079D9821E3867900D15A0D /* javascript.pdf */,
    1.93 +			);
    1.94 +			path = "PDF Security Tests";
    1.95 +			sourceTree = "<group>";
    1.96 +		};
    1.97  		4918EBF91E783C70006207FC /* Models */ = {
    1.98  			isa = PBXGroup;
    1.99  			children = (
   1.100 @@ -3145,10 +3168,12 @@
   1.101  				43F7F07C1F6AD4FD00BDF151 /* HandshakeTests_mail_001.txt in Resources */,
   1.102  				43C3B16820038B2500ED48A4 /* IOS-884_001_test010@peptest.ch.pub.key in Resources */,
   1.103  				436795FB1EE98E9900B03E23 /* CommunicationTypeTests_test002@peptest.ch_sec.asc in Resources */,
   1.104 +				49DCCD2721E8ABD600ABE487 /* javascript.pdf in Resources */,
   1.105  				43628766213D7A5E0066CD03 /* IOS-1300_odt_attachment.txt in Resources */,
   1.106  				436D0066215B5F3800966CC2 /* Undisplayable_HTML_Message.txt in Resources */,
   1.107  				438F4EE9215FB99400168B5E /* Leon Kowalski (19B9EE3B) – Private.asc in Resources */,
   1.108  				430C80D61D0EAB6E00CD4582 /* pEpTrustWords.bundle in Resources */,
   1.109 +				49DCCD2621E8ABD300ABE487 /* nojavascript.pdf in Resources */,
   1.110  				436796001EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch.asc in Resources */,
   1.111  				436796021EE9909100B03E23 /* CommunicationTypeTests_Message_test001_to_test002.txt in Resources */,
   1.112  				438F4EE1215F9CB300168B5E /* SimplifiedKeyImport_Harry_To_Rick_with_Leon.txt in Resources */,
   1.113 @@ -3169,6 +3194,7 @@
   1.114  				43B2C31B1D2280ED00A08557 /* 5A90_3590_0E48_AB85_F3DB__045E_4623_C5D1_EAB6_643E.asc in Resources */,
   1.115  				433F2E2A21E3581800E1CA49 /* ENGINE-505_Mail_NullInnerMimeType.txt in Resources */,
   1.116  				1568FEA11FACDCC600993EA3 /* IOS-211_hi_there.txt in Resources */,
   1.117 +				43D3F8A121EDDF19002D5AFC /* ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt in Resources */,
   1.118  				153CA6E81FB61B53003C9629 /* IOS-815_pep_rating_zero.txt in Resources */,
   1.119  				436795FC1EE98E9900B03E23 /* CommunicationTypeTests_test002@peptest.ch.asc in Resources */,
   1.120  				43A384812153E4BF006AC8F8 /* 8B691AD204E22FD1BF018E0D6C9EAD5A798018D1_pub_sec.txt in Resources */,
   1.121 @@ -3730,6 +3756,7 @@
   1.122  				43C3B1602003851100ED48A4 /* DecryptImportedMessagesTests.swift in Sources */,
   1.123  				1500199F1F2BA2EF003E670A /* SyncFlagsToServerOperationTest.swift in Sources */,
   1.124  				432F7D611D2102F10094F097 /* PEPSessionTest.swift in Sources */,
   1.125 +				49DCCD2821E8ABDF00ABE487 /* ScreenshotTestUtil.swift in Sources */,
   1.126  				157743B8217885EA0007222C /* RecipientTextViewModelTest.swift in Sources */,
   1.127  				151F7205202A070E0057C74D /* PantomimeFolderAttribute+ExtensionsTest.swift in Sources */,
   1.128  				43504D4420E0DD0E00D11E52 /* EmailListViewModeTests+Threading.swift in Sources */,
   1.129 @@ -3769,6 +3796,7 @@
   1.130  				43D86EB821BE62DD00C18418 /* Log+ASL.swift in Sources */,
   1.131  				5DEBAA481DE59C3B00FAE12C /* NetworkServiceTests.swift in Sources */,
   1.132  				157C05482180756300E530DE /* DocumentAttachmentPickerViewModelTest.swift in Sources */,
   1.133 +				49DCCD2521E8ABA900ABE487 /* SecurePDFScreenshotTest.swift in Sources */,
   1.134  				151F7200202A06760057C74D /* TestUtil.swift in Sources */,
   1.135  				43FE8030209995AD00E97AB3 /* QualifyServerIsLocalServiceTest.swift in Sources */,
   1.136  				15D439A7216FB77600EB3933 /* UnitTestUtils.swift in Sources */,
     2.1 --- a/pEpForiOS/Background/DecryptMessageOperation.swift	Tue Jan 15 15:32:35 2019 +0100
     2.2 +++ b/pEpForiOS/Background/DecryptMessageOperation.swift	Wed Jan 16 14:18:47 2019 +0100
     2.3 @@ -85,7 +85,8 @@
     2.4              delegate?.decryptMessageOperation(sender: self, didDecryptMessageWithResult: result)
     2.5  
     2.6          } catch {
     2.7 -            Logger.backendLogger.errorAndCrash("Error decrypting")
     2.8 +            Logger.backendLogger.errorAndCrash("Error decrypting: %{public}@",
     2.9 +                                               error.localizedDescription)
    2.10              delegate?.decryptMessageOperation(sender: self, failed: error)
    2.11          }
    2.12      }
     3.1 --- a/pEpForiOS/Base.lproj/Main.storyboard	Tue Jan 15 15:32:35 2019 +0100
     3.2 +++ b/pEpForiOS/Base.lproj/Main.storyboard	Wed Jan 16 14:18:47 2019 +0100
     3.3 @@ -107,11 +107,10 @@
     3.4                                              </subviews>
     3.5                                          </stackView>
     3.6                                          <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" image="pEp-status-yellow" translatesAutoresizingMaskIntoConstraints="NO" id="m0u-Jn-mQU">
     3.7 -                                            <rect key="frame" x="56" y="50" width="20" height="20"/>
     3.8 +                                            <rect key="frame" x="56" y="52.5" width="20" height="20"/>
     3.9                                              <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
    3.10                                              <constraints>
    3.11 -                                                <constraint firstAttribute="width" constant="20" id="Kc3-zI-6iP"/>
    3.12 -                                                <constraint firstAttribute="width" secondItem="m0u-Jn-mQU" secondAttribute="height" multiplier="1:1" id="fnp-Yy-49g"/>
    3.13 +                                                <constraint firstAttribute="width" secondItem="m0u-Jn-mQU" secondAttribute="height" multiplier="1:1" id="7pr-8F-BtP"/>
    3.14                                              </constraints>
    3.15                                          </imageView>
    3.16                                      </subviews>
    3.17 @@ -122,15 +121,14 @@
    3.18                                          <constraint firstItem="tWZ-jW-sUg" firstAttribute="top" secondItem="jgQ-nZ-h1r" secondAttribute="top" constant="5" id="HLH-Yf-Zeb"/>
    3.19                                          <constraint firstItem="BvI-Zi-zU6" firstAttribute="top" secondItem="5Py-55-oem" secondAttribute="bottom" constant="4" id="Hex-Vv-UnE"/>
    3.20                                          <constraint firstItem="8QD-qP-0hS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="tWZ-jW-sUg" secondAttribute="trailing" constant="8" id="Qdc-6I-SDj"/>
    3.21 -                                        <constraint firstItem="m0u-Jn-mQU" firstAttribute="top" secondItem="YqR-ga-Tf9" secondAttribute="bottom" constant="-15" id="Sx7-Tx-Icx"/>
    3.22                                          <constraint firstItem="YqR-ga-Tf9" firstAttribute="leading" secondItem="jgQ-nZ-h1r" secondAttribute="leadingMargin" id="UBA-wX-ANZ"/>
    3.23                                          <constraint firstItem="BvI-Zi-zU6" firstAttribute="leading" secondItem="5Py-55-oem" secondAttribute="leading" id="Wva-Nq-D3D"/>
    3.24                                          <constraint firstItem="5Py-55-oem" firstAttribute="top" secondItem="tWZ-jW-sUg" secondAttribute="bottom" constant="4" id="Xp7-Lw-Lqg"/>
    3.25                                          <constraint firstItem="MZJ-bg-Dw7" firstAttribute="leading" secondItem="5Py-55-oem" secondAttribute="trailing" constant="3" id="acU-9j-7hJ"/>
    3.26 -                                        <constraint firstItem="m0u-Jn-mQU" firstAttribute="leading" secondItem="YqR-ga-Tf9" secondAttribute="trailing" constant="-10" id="cBb-jj-QAm"/>
    3.27 +                                        <constraint firstItem="BvI-Zi-zU6" firstAttribute="leading" secondItem="m0u-Jn-mQU" secondAttribute="trailing" constant="5" id="co3-bq-uE3"/>
    3.28                                          <constraint firstItem="tWZ-jW-sUg" firstAttribute="bottom" secondItem="8QD-qP-0hS" secondAttribute="bottom" id="dxm-I0-Sij"/>
    3.29 -                                        <constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="m0u-Jn-mQU" secondAttribute="bottom" constant="5" id="fh8-Hb-h3l"/>
    3.30                                          <constraint firstItem="MZJ-bg-Dw7" firstAttribute="trailing" secondItem="8QD-qP-0hS" secondAttribute="trailing" id="hA7-ed-KYt"/>
    3.31 +                                        <constraint firstItem="BvI-Zi-zU6" firstAttribute="bottom" secondItem="m0u-Jn-mQU" secondAttribute="bottom" id="jxk-IK-xXR"/>
    3.32                                          <constraint firstItem="YqR-ga-Tf9" firstAttribute="centerY" secondItem="jgQ-nZ-h1r" secondAttribute="centerY" id="kzK-1E-vdU"/>
    3.33                                          <constraint firstAttribute="trailing" secondItem="8QD-qP-0hS" secondAttribute="trailing" constant="8" id="n5I-Yb-okr"/>
    3.34                                          <constraint firstItem="BvI-Zi-zU6" firstAttribute="trailing" secondItem="8QD-qP-0hS" secondAttribute="trailing" id="tYc-Ao-foD"/>
    3.35 @@ -142,8 +140,6 @@
    3.36                                      <outlet property="attachmentIcon" destination="3BC-6k-zL0" id="ZMO-5d-OGj"/>
    3.37                                      <outlet property="contactImageView" destination="YqR-ga-Tf9" id="E2c-EP-D1U"/>
    3.38                                      <outlet property="dateLabel" destination="Wkg-wf-Dbd" id="TSP-tH-GR2"/>
    3.39 -                                    <outlet property="fakeRatingImageToContactImageHorizontal" destination="cBb-jj-QAm" id="6Ij-h3-mrC"/>
    3.40 -                                    <outlet property="fakeRatingImageToContactImageVertical" destination="Sx7-Tx-Icx" id="Lbz-1T-Kse"/>
    3.41                                      <outlet property="flaggedImageView" destination="BLq-0g-OgR" id="a6H-Fv-kDq"/>
    3.42                                      <outlet property="messageCountLabel" destination="DaU-dh-sn5" id="iBa-MU-sGd"/>
    3.43                                      <outlet property="ratingImage" destination="m0u-Jn-mQU" id="Xod-5v-9K3"/>
    3.44 @@ -940,9 +936,9 @@
    3.45          <image name="unread-icon" width="25" height="25"/>
    3.46      </resources>
    3.47      <inferredMetricsTieBreakers>
    3.48 -        <segue reference="RTR-We-Kc1"/>
    3.49 +        <segue reference="d5O-Wk-gjZ"/>
    3.50          <segue reference="0zl-tV-6Kr"/>
    3.51          <segue reference="anx-J8-OKE"/>
    3.52 -        <segue reference="Usl-iS-7fo"/>
    3.53 +        <segue reference="fJ0-cY-ZEb"/>
    3.54      </inferredMetricsTieBreakers>
    3.55  </document>
     4.1 --- a/pEpForiOS/Util/Logger.swift	Tue Jan 15 15:32:35 2019 +0100
     4.2 +++ b/pEpForiOS/Util/Logger.swift	Wed Jan 16 14:18:47 2019 +0100
     4.3 @@ -194,6 +194,8 @@
     4.4                  filePath: filePath,
     4.5                  fileLine: fileLine,
     4.6                  args: args)
     4.7 +
     4.8 +        // This will omit the arguments, but it's still matchable
     4.9          SystemUtils.crash("\(message)")
    4.10      }
    4.11  
     5.1 --- a/pEpForiOSTests/DecryptImportedMessagesTests.swift	Tue Jan 15 15:32:35 2019 +0100
     5.2 +++ b/pEpForiOSTests/DecryptImportedMessagesTests.swift	Wed Jan 16 14:18:47 2019 +0100
     5.3 @@ -203,6 +203,43 @@
     5.4      }
     5.5       */
     5.6  
     5.7 +    // ENGINE-456 / IOS-1258
     5.8 +    /*
     5.9 +    func test_ENGINE_459() {
    5.10 +        let cdOwnAccount = DecryptionUtil.createLocalAccount(
    5.11 +            ownUserName: "ThisIsMe",
    5.12 +            ownUserID: "User_Me",
    5.13 +            ownEmailAddress: "iostest010@peptest.ch")
    5.14 +
    5.15 +        self.backgroundQueue = OperationQueue()
    5.16 +        let cdMessage = DecryptionUtil.decryptTheMessage(
    5.17 +            testCase: self,
    5.18 +            backgroundQueue: backgroundQueue,
    5.19 +            cdOwnAccount: cdOwnAccount,
    5.20 +            fileName: "ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt")
    5.21 +
    5.22 +        guard let theCdMessage = cdMessage else {
    5.23 +            XCTFail()
    5.24 +            return
    5.25 +        }
    5.26 +
    5.27 +        XCTAssertEqual(theCdMessage.pEpRating, Int16(PEP_rating_unencrypted.rawValue))
    5.28 +        XCTAssertEqual(theCdMessage.shortMessage,
    5.29 +                       "Re: Help needed debugging segfault with Guile 1.8.7")
    5.30 +        XCTAssertNil(theCdMessage.longMessage)
    5.31 +
    5.32 +        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
    5.33 +        XCTAssertEqual(attachments.count, 2)
    5.34 +
    5.35 +        guard let msg = theCdMessage.message() else {
    5.36 +            XCTFail()
    5.37 +            return
    5.38 +        }
    5.39 +
    5.40 +        XCTAssertEqual(msg.attachments.count, 1)
    5.41 +    }
    5.42 +     */
    5.43 +
    5.44      // MARK: - Helpers
    5.45  
    5.46      func check(attachments: [MimeProtocol]) {
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/pEpForiOSTests/PDF Security Tests/SecurePDFScreenshotTest.swift	Wed Jan 16 14:18:47 2019 +0100
     6.3 @@ -0,0 +1,174 @@
     6.4 +//
     6.5 +//  PDFSecurityUITest.swift
     6.6 +//  pEpForiOSUITests
     6.7 +//
     6.8 +//  Created by Miguel Berrocal Gómez on 02/01/2019.
     6.9 +//  Copyright © 2019 p≡p Security S.A. All rights reserved.
    6.10 +//
    6.11 +
    6.12 +import XCTest
    6.13 +
    6.14 +@testable import pEpForiOS
    6.15 +@testable import QuickLook
    6.16 +
    6.17 +class SecurePDFScreenshotTest: XCTestCase {
    6.18 +
    6.19 +    private var javascriptDataSource: PDFDatasource!
    6.20 +    private var nonJavascriptDataSource: PDFDatasource!
    6.21 +    private var bundle: Bundle!
    6.22 +
    6.23 +    //Time to wait to take the screenshot, necessary as the pdf shows a page indicator that fades away.
    6.24 +    private let screenshotDelay = 5.0
    6.25 +
    6.26 +    private let currentScreenshotFileName = "PDFTestScreenshot"
    6.27 +    private let expectedScreenshotFileName = "PDFExpectedScreenshot"
    6.28 +
    6.29 +
    6.30 +    override func setUp() {
    6.31 +        bundle = Bundle(for: type(of: self))
    6.32 +        let javascriptPDFUrl: URL! = bundle.url(forResource: "javascript", withExtension: "pdf")
    6.33 +        let nonJavascriptPDFUrl: URL! = bundle.url(forResource: "nojavascript", withExtension: "pdf")
    6.34 +        javascriptDataSource = PDFDatasource(url: javascriptPDFUrl)
    6.35 +        nonJavascriptDataSource = PDFDatasource(url: nonJavascriptPDFUrl)
    6.36 +    }
    6.37 +
    6.38 +    func testJavascriptDoesNotRunOnQuickLook() {
    6.39 +        let screenShotsDidHappenExpectation = expectation(description: "Screenshots should happen")
    6.40 +        givenScreenshotsOfNonJavascriptAndJavascriptPDFs { (result) in
    6.41 +            switch result {
    6.42 +            case .failure(let reason):
    6.43 +                XCTFail(reason)
    6.44 +            case .success(result: let screenshots):
    6.45 +                let imagesAreTheSame = screenshots.0 == screenshots.1
    6.46 +                XCTAssertTrue(imagesAreTheSame)
    6.47 +                screenShotsDidHappenExpectation.fulfill()
    6.48 +            }
    6.49 +        }
    6.50 +        wait(for: [screenShotsDidHappenExpectation], timeout: ScreenshotTestUtil.waitTime)
    6.51 +    }
    6.52 +
    6.53 +    //PRAGMA MARK: GIVEN
    6.54 +
    6.55 +    private func givenAScreenshotOfQuicklookWithAJavascriptPDF(completion: @escaping (Result<Data>) -> ()) {
    6.56 +        let quickLook = givenAQuickLookLoadedWithAJavascriptPDF()
    6.57 +        screenshotOfViewControllerToPresent(viewController: quickLook, name: self.currentScreenshotFileName, completion: completion)
    6.58 +    }
    6.59 +
    6.60 +    private func givenAScreenshotOfQuicklookWithANonJavascriptPDF(completion: @escaping (Result<Data>) -> ()) {
    6.61 +        let quickLook = givenAQuickLookLoadedWithANonJavascriptPDF()
    6.62 +        screenshotOfViewControllerToPresent(viewController: quickLook, name: self.expectedScreenshotFileName, completion: completion)
    6.63 +    }
    6.64 +
    6.65 +    private func givenScreenshotsOfNonJavascriptAndJavascriptPDFs(completion: @escaping (Result<(Data,Data)>) -> ()) {
    6.66 +        givenAScreenshotOfQuicklookWithANonJavascriptPDF { (result) in
    6.67 +            switch result {
    6.68 +            case .failure(let reason):
    6.69 +                completion(.failure(reason))
    6.70 +
    6.71 +            case .success(result: let nonJavascriptScreenshot):
    6.72 +                self.givenAScreenshotOfQuicklookWithAJavascriptPDF {(result) in
    6.73 +                    switch result {
    6.74 +                    case .failure(let reason):
    6.75 +                        completion(.failure(reason))
    6.76 +                    case .success(result: let javascriptScreenshot):
    6.77 +                        completion(.success(result: (nonJavascriptScreenshot, javascriptScreenshot)))
    6.78 +                    }
    6.79 +                }
    6.80 +            }
    6.81 +        }
    6.82 +    }
    6.83 +
    6.84 +    private func screenshotOfViewControllerToPresent(viewController: UIViewController, name: String, completion: @escaping (Result<Data>) -> ()) {
    6.85 +        present(viewController: viewController) { (didSucceed) in
    6.86 +            guard didSucceed else {
    6.87 +                completion(.failure("Could not present viewController"))
    6.88 +                return
    6.89 +            }
    6.90 +            ScreenshotTestUtil.takeScreenshot(of: viewController.view, after: self.screenshotDelay, name: name) { maybeImageData in
    6.91 +                guard let imageData = maybeImageData else {
    6.92 +                    completion(.failure("There were problems creating the screenshot"))
    6.93 +                    return
    6.94 +                }
    6.95 +                viewController.dismiss(animated: true) {
    6.96 +                    completion(.success(result: imageData))
    6.97 +                }
    6.98 +            }
    6.99 +        }
   6.100 +    }
   6.101 +
   6.102 +    private func givenAQuickLookLoadedWithAJavascriptPDF() -> QLPreviewController {
   6.103 +        return givenAQuickLookWith(dataSource: javascriptDataSource)
   6.104 +
   6.105 +    }
   6.106 +
   6.107 +    private func givenAQuickLookLoadedWithANonJavascriptPDF() -> QLPreviewController {
   6.108 +        return givenAQuickLookWith(dataSource: nonJavascriptDataSource)
   6.109 +    }
   6.110 +
   6.111 +    private func givenAQuickLookWith(dataSource: QLPreviewControllerDataSource) -> QLPreviewController {
   6.112 +        let quickLook = QLPreviewController()
   6.113 +        quickLook.dataSource = dataSource
   6.114 +        return quickLook
   6.115 +    }
   6.116 +
   6.117 +    //PRAGMA MARK: UTILS
   6.118 +
   6.119 +    private func present(viewController: UIViewController, completion: ((Bool) -> ())? = nil) {
   6.120 +        var didSucceed = false
   6.121 +        let windows = UIApplication.shared.windows
   6.122 +        guard windows.count > 0, let rootViewController = windows[0].rootViewController else {
   6.123 +            completion?(didSucceed)
   6.124 +            return
   6.125 +        }
   6.126 +        rootViewController.present(viewController, animated: true) {
   6.127 +            didSucceed = true
   6.128 +            completion?(didSucceed)
   6.129 +        }
   6.130 +    }
   6.131 +
   6.132 +    private func getBundleImageDataFor(name:String) -> Data? {
   6.133 +        let url = bundle.url(forResource: name, withExtension: nil)!
   6.134 +        return try? Data(contentsOf: url)
   6.135 +    }
   6.136 +
   6.137 +    private enum Result<T> {
   6.138 +        case success(result: T)
   6.139 +        case failure(String)
   6.140 +    }
   6.141 +
   6.142 +    private class PDFDatasource: QLPreviewControllerDataSource {
   6.143 +
   6.144 +        class PreviewItem: NSObject, QLPreviewItem {
   6.145 +
   6.146 +            let title: String
   6.147 +            let url: URL
   6.148 +
   6.149 +            var previewItemTitle: String? {
   6.150 +                return title
   6.151 +            }
   6.152 +
   6.153 +            var previewItemURL: URL? {
   6.154 +                return url
   6.155 +            }
   6.156 +
   6.157 +            init(title: String, url: URL) {
   6.158 +                self.title = title
   6.159 +                self.url = url
   6.160 +            }
   6.161 +        }
   6.162 +
   6.163 +        let url: URL
   6.164 +
   6.165 +        init(url: URL) {
   6.166 +            self.url = url
   6.167 +        }
   6.168 +
   6.169 +        func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
   6.170 +            return 1
   6.171 +        }
   6.172 +
   6.173 +        func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
   6.174 +            return PreviewItem(title: "Test", url: url)
   6.175 +        }
   6.176 +    }
   6.177 +}
     7.1 Binary file pEpForiOSTests/PDF Security Tests/javascript.pdf has changed
     8.1 Binary file pEpForiOSTests/PDF Security Tests/nojavascript.pdf has changed
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/pEpForiOSTests/Resources/ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt	Wed Jan 16 14:18:47 2019 +0100
     9.3 @@ -0,0 +1,96 @@
     9.4 +Return-Path: <miguel@pep-project.org>
     9.5 +X-Original-To: iostest010@peptest.ch
     9.6 +Delivered-To: iostest010@peptest.ch
     9.7 +Received: from dragon.pibit.ch (dragon.pibit.ch [94.231.81.244])
     9.8 +	by peptest.ch (Postfix) with ESMTPS id 8AAE1A135B
     9.9 +	for <iostest010@peptest.ch>; Tue, 14 Aug 2018 18:13:49 +0200 (CEST)
    9.10 +Authentication-Results: plesk.peptest.ch;
    9.11 +	spf=none (sender IP is 94.231.81.244) smtp.mailfrom=miguel@pep-project.org smtp.helo=dragon.pibit.ch
    9.12 +Received-SPF: none (plesk.peptest.ch: no valid SPF record)
    9.13 +Received: from localhost (localhost [127.0.0.1])
    9.14 +	by dragon.pibit.ch (Postfix) with ESMTP id DC59B171C06F
    9.15 +	for <iostest010@peptest.ch>; Tue, 14 Aug 2018 18:13:46 +0200 (CEST)
    9.16 +Received: from dragon.pibit.ch ([127.0.0.1])
    9.17 +	by localhost (dragon.pibit.ch [127.0.0.1]) (amavisd-new, port 10024)
    9.18 +	with ESMTP id bfNTZ4O06J0V for <iostest010@peptest.ch>;
    9.19 +	Tue, 14 Aug 2018 18:13:45 +0200 (CEST)
    9.20 +Received: from [192.168.2.140] (95.red-83-39-224.dynamicip.rima-tde.net [83.39.224.95])
    9.21 +	by dragon.pibit.ch (Postfix) with ESMTPSA id E9232171C055
    9.22 +	for <iostest010@peptest.ch>; Tue, 14 Aug 2018 18:13:44 +0200 (CEST)
    9.23 +Subject: Re: pub key
    9.24 +To: Ios008 <iostest010@peptest.ch>
    9.25 +References: <07050b9d-86e7-1d1e-1533-c40eeb2d5482@pep-project.org>
    9.26 + <B2AFA974.42ED.4B77.A619.343B32AEEAFD@pretty.Easy.privacy>
    9.27 +From: Miguel Berrocal <miguel@pep-project.org>
    9.28 +Openpgp: preference=signencrypt
    9.29 +Autocrypt: addr=miguel@pep-project.org; keydata=
    9.30 + xsBNBFsOU8oBCACyiVjmxdr5HNbGy63J2ijYcDxe+N6w/i3rFYhhp+rg7VZl0xgF3U4naVEg
    9.31 + ANVW9qeDW8BckCgp3TEevWceFispBQxc9u2xfQ6KJM7ybdM9kRigucUJ7xe77ryDZqOa0sCb
    9.32 + GYNZWm1wJ4FLzXyJK2nPtbuOTHl3FrhbKojsj+d25BkSKxfB2EmBXvGsFgFrv4qgRYK9jHpm
    9.33 + rizOjhvC3Uh4uTtlvXiLBl8rpYQC5dE8IChzR4a1tRKR6fW/0ij7ukEfI/USE22nu3NJCQ5w
    9.34 + ADCoDs+/iGt2JHhiGXkad4yoCqfQeywHv3d5hGwI95cBj+gkueEZ1ILmWmutPRORLX9lABEB
    9.35 + AAHNKE1pZ3VlbCBCZXJyb2NhbCA8bWlndWVsQHBlcC1wcm9qZWN0Lm9yZz7CwJQEEwEIAD4W
    9.36 + IQQWzIojy4MIp24qUrPut8vY77QenQUCWw5TzgIbAwUJAeEzgAULCQgHAgYVCgkICwIEFgID
    9.37 + AQIeAQIXgAAKCRDut8vY77QenZDHB/4w5Dl5NcnKnEJGdhulXJlKOR7H7Uj3YB+1K4BJ6B2z
    9.38 + pdtwdZzq5BZqxVMH39TZnx215JDnB2rs585PeaBHlBqc7PyEgeBg8ioOuSY+YLhkGhGb8fFs
    9.39 + ri5u6j8p+vGYyZLnjIDk4O+I14DiYr6x+kitE14oHJYXUFjEODIUFWpoIYn57l9YXaN2YLbD
    9.40 + VRInPKaqonl8+j/vdgPySavh0/iNn1gQxFiHwSAVjCsaOrv1hiZzkVdtpX4pu4qO48EEdUDm
    9.41 + vyUHUfEwG1cYiQ8swHubkGWkX9ELDQs3X4rVwCUAWhawD9yKubg+0X5WgFUvhRZlPgHOvovF
    9.42 + ORAGMrQvsgZ7zsBNBFsOU8oBCADIeIfZHJn7sMcgqrhMRTv+xHDCAvx7kWaq/lBAXjwA8gcM
    9.43 + ScVko7Clmwm0Cwhv9PUhXPOwTDUcP0kpghdLsUkj+9qRw1JIZeZRcd/W+lHwy4NhMa50uS8j
    9.44 + Sri+CtdKl+XU0LCsjZ6RY/y/pIqG9DJUNGIqB2qssVIC5jZ3roE4zGpj4lQTEouBw4ZkFJVU
    9.45 + 96Wk8QaTwgcLmuZf6S/Tmmhsdmdk5UnwuDyeXhVIud5txtD9s5FDKOh85lZUghPM8cKn/adW
    9.46 + bAZbPn5TGRDqXvl0b3csP09FOch0OR+y/FanxAp3oiObyTHHOvDRi94FL+uzWJQUJqkKZxwG
    9.47 + pe7XadeLABEBAAHCwHwEGAEIACYWIQQWzIojy4MIp24qUrPut8vY77QenQUCWw5TygIbDAUJ
    9.48 + AeEzgAAKCRDut8vY77QendB+B/9fwdgLURc+u+Vh6MnkqdPrBQ/Gyi4mQTNShTtXbeVmSsCI
    9.49 + F1dX24ej3K6/4i1IhpBbNLAy8CcgpwDdxOrcz1Zbvr+QynLDOhc5MNiDGWCvQHykdVGRcsgk
    9.50 + V4g9IDO79uMlfZxqMFqugnBQN0j+23tHhPVm6LYnda3YRgtBy5gaJggPSJjLnhFKpUXDKjwj
    9.51 + la+P3eJG4wRJU2fkP5f5d5fGz73gdUjzmMheMGy8icVkAkhjt1J6aWPOHzXmX1TgwazrmD/7
    9.52 + t2gQSXRkz3M2Lm03LonjW242jRe46VB38b2+8A4XiyOZ4qvANtryMLvraZqoQ8PTrT+GivgC
    9.53 + 6bGB1hHe
    9.54 +Message-ID: <457225fe-fe5e-d1d5-61e6-809900a9fab4@pep-project.org>
    9.55 +Date: Tue, 14 Aug 2018 18:13:44 +0200
    9.56 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0)
    9.57 + Gecko/20100101 Thunderbird/52.8.0
    9.58 +MIME-Version: 1.0
    9.59 +In-Reply-To: <B2AFA974.42ED.4B77.A619.343B32AEEAFD@pretty.Easy.privacy>
    9.60 +Content-Type: text/plain; charset=utf-8
    9.61 +Content-Transfer-Encoding: quoted-printable
    9.62 +Content-Language: en-US
    9.63 +
    9.64 +
    9.65 +-----BEGIN PGP MESSAGE-----
    9.66 +Charset: utf-8
    9.67 +
    9.68 +hQIMA9i+prqnpdolAQ//YhAMxUKJX2juEaDUmzATIFxjeeEpUQySjctUZyY9Zh7d
    9.69 +xPKCeW3ClO9160IJvzcuL6+8hUEjesKpejv3V58IGYagTf2Ijzh7a0LxaTRFns5+
    9.70 +OOJZHLPQAoO+7/x3SuusbRt7+GwCIStrsmc1l/OxTQXWlXWmn48czVIiWNJk11CW
    9.71 +eO/fveHp6yka4bb5TqLEMrNrbkXHh0BNHE79h774O4vWOCT4MnDZUEpEdLCANymx
    9.72 +XZMU2nAb8nE46FfVQ2zgAZWIjfxSmeD5oK3bAPhi9VllM5h8rkBNxr1Hxsw+cOkx
    9.73 +lkJhN91qkcqJ0kDIKdtKMRINHD+TSnXrWNmRm/72jQ3oAbbN7hP9Iwfj02Bz3EmR
    9.74 +lI7dyCqZ9Q8lXmKW6IHdCpM1esQXcsUzpVVDWd7aXpJA6ERquD8BZDpeBeuwmVYv
    9.75 +0M+w3woxDbSCVgCFdrTydT++5+75ySnhB2GgXC9aIrNE9o6vX1H4AkCUn6JX9rRa
    9.76 +98Pc/17CLw/h300Y0N3eUbmt2l8jAuAg8TfX7kwrizV+1DWZGjygp7b0IZfaXLnV
    9.77 +67+tJsyNdAUJmX4PDCEe6IfehAoqqS2p3en9SVYT/AHPUynldZfkv1U+eFUbf++s
    9.78 +5gbSPsre8m2TWhcq2taa/yZ518bl+PRmNqRtgIOpH8aoQ+FIJKJlzIrsjP4TUCiF
    9.79 +AQwD1AuaqsbpiesBB/96kN12Olm0W4MbmMtTIXOuLjmdF+WcZsU7stlQySMdS2Si
    9.80 +IRVs34SwOr516cze6YAGTbludMK3eLmUOibtzobmoXfIHNycoFX1mQvcAbUxOO7U
    9.81 +X0a8/MM/ZH12kUpu+VgUGvMvcEOYSSakO/7m2NplePfjboFsSdsI2bEoz0jt5npi
    9.82 +q1z1MzPRAtAqnPVw2ikACg5cZBccxcw7+GPQaMNXsPe/mED0Bg59WFCN+/9bjsRq
    9.83 +dmH+F88BJtSne1juJ3g3vqB1qmVXPn5gJehlZx1XjOYmkkgpI2x91g522wYuY/qg
    9.84 +iu+Cmb2rFmyaYFua8ngcmphafcm97hGNscYYDeKT0ukB81tPHt8QyjROFv7R3J/v
    9.85 +ariSzHU4ldZTYc4T+hEr5HqEc1npcLuTb32CFYsZCFED91C+LXIASujYqX2CaoJU
    9.86 +uSMBU4wpFCiiaRcpr1xCFAKNguQyDlkoziKMc7ZTTqaECZg3sV0nwU8WYBrHzlnP
    9.87 +tpLu7NgdabWzzV7XmwdSb10CX6O2aaDui8o/V/P5NASkb1ffHUwlBx1KiocWLgUs
    9.88 +8Xq8jfTl3O3QAoJVLThtZkx9wrM3QDrISp8aaZEtTh0P3G3OQLiiGQycuRzkhSox
    9.89 +3o/Pomtxobe1bmwbEQ0KItSNcUVfXfrQoUJLWustHtHPouFJUxlxqtGUNP5gti/B
    9.90 +/m+KAa8etLYf/R6mDSfbIUpoBdigSm0DwTMAzvN5wz61oarLIiSrgbNSQSCABjSa
    9.91 +R44us3iMBTilNcIPdw00iakGILvKnUUROeSgBnqs9WP1Pa5yjI2vZwHdgXfZP66i
    9.92 +Q2aLRS9bZ98N+oOJbGsdIiWeB1hJYUNZgsdJjjk9PiLDC3UPBZ7cwDeeb7QVG+EU
    9.93 +tj/ynAXqGeXNrqWdswLGoAGBQWylIO2GGzKCuvwd4znTrdDAmR+nE3Tuamom/32W
    9.94 +oPmsBECnOWcv1emVGCk3JvnRzwtosKqIRaP/zZ69u46VIGbLxIQ0P+KLE6yhlW8q
    9.95 +MNxwpgjDJLt5oKs9A3U/RxWeP21sAduR1cXONcdmr40VQ49tD9c=3D
    9.96 +=3DXT6q
    9.97 +-----END PGP MESSAGE-----
    9.98 +
    9.99 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/pEpForiOSTests/TestUtils/ScreenshotTestUtil.swift	Wed Jan 16 14:18:47 2019 +0100
    10.3 @@ -0,0 +1,62 @@
    10.4 +//
    10.5 +//  ScreenshotTestUtil.swift
    10.6 +//  pEpForiOSTests
    10.7 +//
    10.8 +//  Created by Miguel Berrocal Gómez on 09/01/2019.
    10.9 +//  Copyright © 2019 p≡p Security S.A. All rights reserved.
   10.10 +//
   10.11 +
   10.12 +import UIKit
   10.13 +
   10.14 +class ScreenshotTestUtil {
   10.15 +
   10.16 +    /// The maximum wait time for screenshot tests.
   10.17 +    static let waitTime: TimeInterval = 30
   10.18 +
   10.19 +    static func getImageData(image: UIImage) -> Data? {
   10.20 +        return UIImageJPEGRepresentation(image, 1)
   10.21 +    }
   10.22 +
   10.23 +    static func takeScreenshot(of view: UIView, after seconds:TimeInterval, name: String = "screenshot", completion: @escaping (Data?) -> () ) {
   10.24 +        DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
   10.25 +            guard let image = self.takeSnapshotOfView(view: view),
   10.26 +                let data = self.getImageData(image: image) else {
   10.27 +                    completion(nil)
   10.28 +                    return
   10.29 +            }
   10.30 +            self.saveData(fileName: name, data: data) //Used to debug or to update test image when non harmful UI changes happen
   10.31 +            completion(data)
   10.32 +        }
   10.33 +    }
   10.34 +
   10.35 +    static func saveImage(imageName: String, image: UIImage) {
   10.36 +        guard let data = getImageData(image: image) else { return }
   10.37 +        saveData(fileName: imageName, data: data)
   10.38 +    }
   10.39 +
   10.40 +    static func saveData(fileName: String, data: Data) {
   10.41 +        guard let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
   10.42 +        let fileURL = documentsDirectory.appendingPathComponent(fileName)
   10.43 +
   10.44 +        if FileManager.default.fileExists(atPath: fileURL.path) {
   10.45 +            do {
   10.46 +                try FileManager.default.removeItem(atPath: fileURL.path)
   10.47 +            } catch let removeError {
   10.48 +                print("couldn't remove file at path", removeError)
   10.49 +            }
   10.50 +        }
   10.51 +        do {
   10.52 +            try data.write(to: fileURL)
   10.53 +        } catch let error {
   10.54 +            print("error saving file with error", error)
   10.55 +        }
   10.56 +    }
   10.57 +
   10.58 +    static func takeSnapshotOfView(view:UIView) -> UIImage? {
   10.59 +        UIGraphicsBeginImageContext(CGSize(width: view.frame.size.width, height: view.frame.size.height))
   10.60 +        view.drawHierarchy(in: CGRect(x: 0.0, y: 0.0, width: view.frame.size.width, height: view.frame.size.height), afterScreenUpdates: true)
   10.61 +        let image = UIGraphicsGetImageFromCurrentImageContext()
   10.62 +        UIGraphicsEndImageContext()
   10.63 +        return image
   10.64 +    }
   10.65 +}