private void CaptureAdded(uint ID, string executable, string api, byte[] thumbnail, DateTime timestamp) { if (thumbnail == null || thumbnail.Length == 0) { using (Image t = MakeThumb(thumbs.ImageSize, null)) { thumbs.Images.Add(t); } } else { using (var ms = new MemoryStream(thumbnail)) using (Image t = MakeThumb(thumbs.ImageSize, ms)) { thumbs.Images.Add(t); } } CaptureLog log = new CaptureLog(); log.remoteID = ID; log.exe = executable; log.api = api; log.timestamp = timestamp; log.copying = true; log.saved = false; var item = new ListViewItem(new string[] { log.exe + " (Copying)", log.api, log.timestamp.ToString() }, thumbs.Images.Count - 1); item.Tag = log; item.SubItems[0].Font = new Font(item.SubItems[0].Font, FontStyle.Italic); captures.Items.Add(item); }
private bool SaveCapture(CaptureLog log) { if (log.copying) { return(false); } string path = m_Main.GetSavePath(); // we copy the temp log to the desired path, but the log item remains referring to the temp path. // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { try { File.Copy(log.localpath, path, true); log.saved = true; m_Core.Config.AddRecentFile(m_Core.Config.RecentLogFiles, path, 10); m_Main.PopulateRecentFiles(); } catch (System.Exception ex) { MessageBox.Show("Couldn't save to " + path + Environment.NewLine + ex.ToString(), "Cannot save", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); } return(false); }
public void CaptureWrongOrder() => Assert.Throws <InvalidOperationException>(() => { using (var captureLog = new CaptureLog(_capturePath, _filePath, false)) { captureLog.StopCapture(); } });
public void CaptureWrongOrderEntirePath() { using (var captureLog = new CaptureLog(_capturePath, _filePath, true)) { captureLog.StopCapture(); } }
public void ExitCodeFromPreviousRunIsIgnored() { var previousLog = "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class MockAKSRefKeyObject is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b738) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x103259970). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class MockAKSOptionalParameters is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b788) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x1032599c0). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class SecXPCHelper is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b918) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x103259a60). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 ML-MacVM com.apple.CoreSimulator.SimDevice.2E1EE736-5672-4220-89B5-B7C77DB6AF18[55655] (UIKitApplication:net.dot.HelloiOS[9a0b][rb-legacy][57331]): Some other error message" + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 ML-MacVM com.apple.CoreSimulator.SimDevice.2E1EE736-5672-4220-89B5-B7C77DB6AF18[55655] (UIKitApplication:net.dot.HelloiOS[9a0b][rb-legacy][57331]): Service exited with abnormal code: 55" + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 com.apple.CoreSimulator.SimDevice.F67392D9-A327-4217-B924-5DA0918415E5[811] (com.apple.security.cloudkeychainproxy3): Service only ran for 0 seconds. Pushing respawn out by 10 seconds." + Environment.NewLine; var currentRunLog = "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class MockAKSRefKeyObject is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b738) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x103259970). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class MockAKSOptionalParameters is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b788) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x1032599c0). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 CloudKeychainProxy[67121]: objc[67121]: Class SecXPCHelper is implemented in both /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/Security (0x10350b918) and /Applications/Xcode115.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CloudKeychainProxy.bundle/CloudKeychainProxy (0x103259a60). One of the two will be used. Which one is undefined." + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 ML-MacVM com.apple.CoreSimulator.SimDevice.2E1EE736-5672-4220-89B5-B7C77DB6AF18[55655] (UIKitApplication:net.dot.HelloiOS[9a0b][rb-legacy][57331]): Some other error message" + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 ML-MacVM com.apple.CoreSimulator.SimDevice.2E1EE736-5672-4220-89B5-B7C77DB6AF18[55655] (UIKitApplication:net.dot.HelloiOS[9a0b][rb-legacy][57331]): Service exited with abnormal code: 72" + Environment.NewLine + "Nov 18 04:31:44 dci-mac-build-053 com.apple.CoreSimulator.SimDevice.F67392D9-A327-4217-B924-5DA0918415E5[811] (com.apple.security.cloudkeychainproxy3): Service only ran for 0 seconds. Pushing respawn out by 10 seconds." + Environment.NewLine; var tempFilename = Path.GetTempFileName(); File.WriteAllText(tempFilename, previousLog); var capturedFilename = Path.GetTempFileName(); using var captureLog = new CaptureLog(capturedFilename, tempFilename, false); captureLog.StartCapture(); File.AppendAllText(tempFilename, currentRunLog); captureLog.StopCapture(); var appBundleInformation = new AppBundleInformation("net.dot.HelloiOS", "net.dot.HelloiOS", "some/path", "some/path", false, null); var exitCode = new iOSExitCodeDetector().DetectExitCode(appBundleInformation, captureLog); Assert.Equal(72, exitCode); }
public void ConstructorNullFilePath() { Assert.Throws <ArgumentNullException>(() => { var captureLog = new CaptureLog(null, _filePath, false); }); }
public void CapturePieceByPiece() { var ignoredLine = "This line should not be captured"; var logLines = new[] { "first line", "second line", "third line" }; File.WriteAllLines(_sourcePath, new[] { ignoredLine }); using var captureLog = new CaptureLog(_destinationPath, _sourcePath, false); captureLog.StartCapture(); File.AppendAllLines(_destinationPath, logLines.Take(1)); captureLog.Flush(); Assert.Contains(logLines.First(), File.ReadAllText(_destinationPath)); File.AppendAllLines(_destinationPath, logLines.Skip(1)); captureLog.StopCapture(); // Get the stream and assert we do have the correct lines using var captureStream = captureLog.GetReader(); string logLine; while ((logLine = captureStream.ReadLine()) != null) { Assert.NotEqual(ignoredLine, logLine); if (!string.IsNullOrEmpty(logLine)) { Assert.Contains(logLine, logLines); } } }
public void CaptureRightOrder() { var ignoredLine = "This lines should not be captured"; var logLines = new[] { "first line", "second line", "thrid line" }; File.WriteAllLines(_filePath, new[] { ignoredLine }); using var captureLog = new CaptureLog(_capturePath, _filePath, false); captureLog.StartCapture(); File.WriteAllLines(_filePath, logLines); captureLog.StopCapture(); // get the stream and assert we do have the correct lines using var captureStream = captureLog.GetReader(); string logLine; while ((logLine = captureStream.ReadLine()) != null) { if (!string.IsNullOrEmpty(logLine)) { Assert.Contains(logLine, logLines); } } }
public void CaptureRightOrder() { var ignoredLine = "This lines should not be captured"; var logLines = new[] { "first line", "second line", "thrid line" }; using (var stream = File.Create(_filePath)) using (var writer = new StreamWriter(stream)) { writer.WriteLine(ignoredLine); } using (var captureLog = new CaptureLog(_capturePath, _filePath, false)) { captureLog.StartCapture(); using (var writer = new StreamWriter(_filePath)) { foreach (var line in logLines) { writer.WriteLine(line); } } captureLog.StopCapture(); // get the stream and assert we do have the correct lines using (var captureStream = captureLog.GetReader()) { string line; while ((line = captureStream.ReadLine()) != null) { Assert.Contains(line, logLines); } } } }
public void CaptureWrongOrder() { Assert.Throws <InvalidOperationException>(() => { using var captureLog = new CaptureLog(_destinationPath, _sourcePath, false); captureLog.StopCapture(); }); }
public void CaptureWrongOrderEntirePath() { Assert.DoesNotThrow(() => { using (var captureLog = new CaptureLog(capturePath, filePath, true)) { captureLog.StopCapture(); } }); }
private void OpenCapture(CaptureLog log) { if (!log.copying) { m_Main.LoadLogfile(log.localpath, !log.saved); log.opened = true; } }
private void CaptureAdded(uint ID, string executable, string api, byte[] thumbnail, DateTime timestamp, string path, bool local) { if (thumbnail == null || thumbnail.Length == 0) { using (Image t = MakeThumb(thumbs.ImageSize, null)) { thumbs.Images.Add(t); } } else { using (var ms = new MemoryStream(thumbnail)) using (Image t = MakeThumb(thumbs.ImageSize, ms)) { thumbs.Images.Add(t); } } CaptureLog log = new CaptureLog(); log.remoteID = ID; log.exe = executable; log.api = api; log.timestamp = timestamp; log.thumb = null; try { if (thumbnail != null && thumbnail.Length != 0) { using (var ms = new MemoryStream(thumbnail)) log.thumb = Image.FromStream(ms); } } catch (ArgumentException) { } log.saved = false; log.path = path; log.local = local; string title = log.exe; if (!local) { title += " (Remote)"; } var item = new ListViewItem(new string[] { title, log.api, log.timestamp.ToString() }, thumbs.Images.Count - 1); item.Tag = log; if (!local) { item.SubItems[0].Font = new Font(item.SubItems[0].Font, FontStyle.Italic); } captures.Items.Add(item); }
public void insertCaptureLog() { CaptureLog captureLog = new CaptureLog(); captureLog.AdapterName = Globals.DeviceInfo.Name; captureLog.StartTime = Globals.StartTime; captureLog.EndTime = DateTime.Now; captureLog.Packets = captNum; captureLog.Bytes = captLen; serviceStackDBHelper.InsertCaptureLog(captureLog); }
private bool SaveCapture(CaptureLog log) { string path = m_Main.GetSavePath(); // we copy the temp log to the desired path, but the log item remains referring to the temp path. // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { try { if (log.local) { File.Copy(log.path, path, true); } else if (m_Connection.Connected) { // if we have a current live connection, prefer using it m_CopyLogLocalPath = path; m_CopyLogID = log.remoteID; } else { if (m_Core.Renderer.Remote == null || m_Core.Renderer.Remote.Hostname != m_Host || !m_Core.Renderer.Remote.Connected) { MessageBox.Show( String.Format("This capture is on remote host {0} and there is no active replay context on that host.\n" + "Without an active replay context the capture cannot be saved, try switching to a replay context on {0}.\n\n", m_Host), "No active replay context", MessageBoxButtons.OK); return(false); } m_Core.Renderer.CopyCaptureFromRemote(log.path, path, this); m_Core.Renderer.DeleteCapture(log.path, false); } log.saved = true; log.path = path; m_Core.Config.AddRecentFile(m_Core.Config.RecentLogFiles, path, 10); m_Main.PopulateRecentFiles(); } catch (System.Exception ex) { MessageBox.Show("Couldn't save to " + path + Environment.NewLine + ex.ToString(), "Cannot save", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); } return(false); }
public void CaptureMissingFileTest() { using (var captureLog = new CaptureLog(capturePath, filePath, false)) { Assert.AreEqual(capturePath, captureLog.FullPath, "capture path"); captureLog.StartCapture(); captureLog.StopCapture(); } // read the data that was added to the capture path and ensure that we do have the name of the missing file using (var reader = new StreamReader(capturePath)) { var line = reader.ReadLine(); StringAssert.Contains(filePath, line, "file path missing"); } }
public void CaptureMissingFileTest() { using (var captureLog = new CaptureLog(_destinationPath, _sourcePath, false)) { Assert.Equal(_destinationPath, captureLog.FullPath); captureLog.StartCapture(); captureLog.StopCapture(); } // Read the data that was added to the capture path and ensure that we do have the name of the missing file using (var reader = new StreamReader(_destinationPath)) { var line = reader.ReadLine(); Assert.Contains(_sourcePath, line); } }
public bool InsertCaptureLog(CaptureLog captureLog) { using (db = dbFactory.Open()) { try { var flag = db.Insert <CaptureLog>(captureLog); if (flag >= 0) { return(true); } } catch (Exception) { } return(false); } }
private void OpenCapture(CaptureLog log) { log.opened = true; if (!log.local && (m_Core.Renderer.Remote == null || m_Core.Renderer.Remote.Hostname != m_Host || !m_Core.Renderer.Remote.Connected) ) { MessageBox.Show( String.Format("This capture is on remote host {0} and there is no active replay context on that host.\n" + "You can either save the log locally, or switch to a replay context on {0}.\n\n", m_Host), "No active replay context", MessageBoxButtons.OK); return; } m_Main.LoadLogfile(log.path, !log.saved, log.local); }
private bool SaveCapture(CaptureLog log) { if (log.copying) { return(false); } string path = m_Main.GetSavePath(); if (path.Length > 0) { File.Copy(log.localpath, path, true); File.Delete(log.localpath); log.localpath = path; log.saved = true; return(true); } return(false); }
public void CaptureEverythingAtOnce() { var logLines = new[] { "first line", "second line", "third line" }; File.WriteAllText(_sourcePath, string.Empty); using var captureLog = new CaptureLog(_destinationPath, _sourcePath, false); captureLog.StartCapture(); File.AppendAllLines(_sourcePath, logLines); captureLog.StopCapture(); // get the stream and assert we do have the correct lines using var captureStream = captureLog.GetReader(); string logLine; while ((logLine = captureStream.ReadLine()) != null) { if (!string.IsNullOrEmpty(logLine)) { Assert.Contains(logLine, logLines); } } }
private void captures_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { deleteMenu.Enabled = (captures.SelectedItems.Count > 0); saveMenu.Enabled = saveThisCaptureToolStripMenuItem.Enabled = openMenu.Enabled = openThisCaptureToolStripMenuItem.Enabled = (captures.SelectedItems.Count == 1); if (captures.SelectedItems.Count == 1) { CaptureLog cap = captures.SelectedItems[0].Tag as CaptureLog; newInstanceToolStripMenuItem.Enabled = cap.local; if (cap.thumb != null) { preview.Image = cap.thumb; } else { preview.Image = null; preview.Size = new Size(16, 16); } } }
private bool SaveCapture(CaptureLog log) { if (log.copying) return false; string path = m_Main.GetSavePath(); // we copy the temp log to the desired path, but the log item remains referring to the temp path. // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { File.Copy(log.localpath, path, true); return true; } return false; }
private bool SaveCapture(CaptureLog log) { if (log.copying) return false; string path = m_Main.GetSavePath(); // we copy the temp log to the desired path, but the log item remains referring to the temp path. // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { try { File.Copy(log.localpath, path, true); } catch (System.Exception ex) { MessageBox.Show("Couldn't save to " + path + Environment.NewLine + ex.ToString(), "Cannot save", MessageBoxButtons.OK, MessageBoxIcon.Error); } return true; } return false; }
private bool SaveCapture(CaptureLog log) { if (log.copying) return false; string path = m_Main.GetSavePath(); if (path != "") { File.Copy(log.localpath, path, true); File.Delete(log.localpath); log.localpath = path; log.saved = true; return true; } return false; }
private bool SaveCapture(CaptureLog log) { string path = m_Main.GetSavePath(); // we copy the temp log to the desired path, but the log item remains referring to the temp path. // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { try { if (log.local) { File.Copy(log.path, path, true); } else if (m_Connection.Connected) { // if we have a current live connection, prefer using it m_CopyLogLocalPath = path; m_CopyLogID = log.remoteID; } else { if (m_Core.Renderer.Remote == null || m_Core.Renderer.Remote.Hostname != m_Host || !m_Core.Renderer.Remote.Connected) { MessageBox.Show( String.Format("This capture is on remote host {0} and there is no active replay context on that host.\n" + "Without an active replay context the capture cannot be saved, try switching to a replay context on {0}.\n\n", m_Host), "No active replay context", MessageBoxButtons.OK); return false; } m_Core.Renderer.CopyCaptureFromRemote(log.path, path, this); m_Core.Renderer.DeleteCapture(log.path, false); } log.saved = true; log.path = path; m_Core.Config.AddRecentFile(m_Core.Config.RecentLogFiles, path, 10); m_Main.PopulateRecentFiles(); } catch (System.Exception ex) { MessageBox.Show("Couldn't save to " + path + Environment.NewLine + ex.ToString(), "Cannot save", MessageBoxButtons.OK, MessageBoxIcon.Error); } return true; } return false; }
private void CaptureAdded(uint ID, string executable, string api, byte[] thumbnail, DateTime timestamp, string path, bool local) { if (thumbnail == null || thumbnail.Length == 0) { using (Image t = MakeThumb(thumbs.ImageSize, null)) { thumbs.Images.Add(t); } } else { using (var ms = new MemoryStream(thumbnail)) using (Image t = MakeThumb(thumbs.ImageSize, ms)) { thumbs.Images.Add(t); } } CaptureLog log = new CaptureLog(); log.remoteID = ID; log.exe = executable; log.api = api; log.timestamp = timestamp; log.thumb = null; try { if (thumbnail != null && thumbnail.Length != 0) { using (var ms = new MemoryStream(thumbnail)) log.thumb = Image.FromStream(ms); } } catch (ArgumentException) { } log.saved = false; log.path = path; log.local = local; string title = log.exe; if (!local) title += " (Remote)"; var item = new ListViewItem(new string[] { title, log.api, log.timestamp.ToString() }, thumbs.Images.Count - 1); item.Tag = log; if(!local) item.SubItems[0].Font = new Font(item.SubItems[0].Font, FontStyle.Italic); captures.Items.Add(item); }
private void OpenCapture(CaptureLog log) { m_Main.LoadLogfile(log.path, !log.saved, log.local); log.opened = true; }