XCTest send multiple key combination - ios

Does someone have an example of how to send multiple key combination when using XCTest / Swift? i.e. How would we send Shift + Command + H to the simulator when running a test?
I see the perform method exists:
perform(withKeyModifiers:block:)
https://developer.apple.com/documentation/xctest/xcuielement/1500563-perform
But not sure how to use it.

Related

Clarification on CoAp implementation for contikiOS

I'm trying to send packets over CoAP between two TI 2650 sensortags. I used the logic from the "er-rest-example" provided by contiki 3.0, that is:
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
coap_set_header_uri_path(request, url);
coap_set_payload(request, (uint8_t*)msg, sizeof(msg) - 1);
COAP_BLOCKING_REQUEST(&server_ip, REMOTE_PORT, request, client_chunk_handler);
When I started the program, it works as expected until the first time COAP_BLOCKING_REQUEST is called, at which point the program seems to freeze (doesn't react to button presses anymore).
So I assume COAP_BLOCKING_REQUEST blocks until it receives a response, which is not suitable for my project. Can anyone confirm that?
UPDATE:
Going forward from that assumption, my question now is, what steps to I have to take to send out a packet?
Do I use the coap_send_message function from er-coap.c or the coap_send_transaction function from er-coap-transaction.c?
I want to figure out what functions I have to call in which order to configure the packet correctly and then send it out with the correct function (which I guess would be one of the above).
Maybe there is some documentation out there that I haven't found yet and someone could point me to it?
Cheers

Sim5360e communication over UART2

I will implement the data exchange between the module and the device Sim5360e through UART2. I write in the Lua, AT commands to send / receive information via the UART2 did not find - so use internal devio function.
sio.send("AT+CSCLK=0\r\n")
readAndPrintAtUnswer()
sio.send("AT+CGFUNC=21,1\r\n")
readAndPrintAtUnswer()
sio.send("AT+IPR2=9600\r\n")
readAndPrintAtUnswer()
local msg,count=getHex(str)
local unswer
devio.open(3)
devio.write(3,msg,count)
unswer=devio.read(3,4000)
print(unswer)
devio.close(3)
When connected to a terminal on the PC - see the correct incoming message, the module enters the mode of reading, I send data through the terminal, but after a timeout (4000 ms) unswer = nil. Data from the terminal out exactly correct - checked by another device.
Can you please tell, how do I get an answer to my message?

Automatically Running a Test Case Many Times in Xcode

In Xcode, is there a way for me run a single test case n times automatically?
Reason for doing this is that some of my beta testers are encountering random crashes in my app. I see the crash logs in TestFlight, along with the stack trace, but I can't reproduce the crash.
The crash happens infrequently but when it does, it always happens when users are trying to create a DB record, which then gets uploaded to a server. The problem with the crash logs is that my code does not make an appearance in their stack traces (all UIKit & CoreFoundation stuff - and different each time).
My solution is to run the test for that part of the app 100s of times, with the exception breakpoint set, to try to trigger the bug in my dev environment. But I don't know how to do this automatically.
It took 7 years, but as of Xcode 13, support for test repetition is now built-in.
From the Xcode 13 release notes:
Enable test repetition in your test plan, xcodebuild, or by running your test from the test diamond by Control-clicking and selecting Run Repeatedly to bring up the test repetition dialog.
You can read my answer here.
Basically you need to override invokeTest method
override func invokeTest() {
for time in 0...15 {
print("this test is being invoked: \(time) times")
super.invokeTest()
}
}
In Xcode as such, no.
You can create an XCTestCase class that hooks into the test-running methods it inherits to return multiple runs, but that tends to be annoying and mostly undocumented.
It's probably easier to instead have a "meta-test" that calls out to your other test method repeatedly:
func testOnce() {}
func testManyTimes() {
for _ in 0..<1000 { testOnce() }
}
You might need to call out to some per-test setup/teardown methods. You could perhaps work around that by instead making the loop body be something like:
let test = XCTestCase(selector: #selector(testOnce))
test.invokeTest()
This would lean on the XCTest machinery that your standard tests use, but it might gripe about not being wired into an XCTestCaseRun (or not).

Simperium Received an Invalid Change

I am developing integration with Simperium, the integration is complete and has been running on test machines for sometime, I am starting to get this error on one of the devices and it keeps repeating constantly any ideas?
MeetingPad[891:1103] Simperium error (ActionLinks82), received an invalid change for (a18852011efe4964a6fdeb1853c790f3)
2013-02-07 10:07:05:277 MeetingPad[891:1103] Simperium client ios-7f43b434754d882923e966df5d885755 received change (ActionLinks82) ios-4176925448fa8ae0a2f1d0937627aa6b: {
ccids = (
3f3b4550b23147d49e194038feea09a6
);
clientid = "ios-4176925448fa8ae0a2f1d0937627aa6b";
cv = 5112df4b37a401031dcc5be1;
ev = 2;
id = 9ca0b7ad04314ab9888d75691be784b5;
o = "-";
}
If this occured on a user account what would be the guidance?
One thing to check is that you're using the latest version of the code. The repository was recently open sourced on GitHub. There used to be a bug related to nil values that could cause an invalid diff to appear in your change stream, but it should be fixed now.
Assuming you're using the latest code though, does the error repeat continuously for the same "id" value, or are there different values?
Looking at the Simperium code where this error occurs, it's possible it could be displayed if you've deleted an object locally and remotely at around the same time. In your app, might ActionLinks fit that pattern, i.e. are you creating and deleting a lot of them across multiple clients?
If that is indeed the cause, then the error is innocuous and we should patch the code. Let me know what you discover.

Data is not stored in database through device

Hi i am new in blackberry i create a blackberry app in this application i am facing a problem
i am try to store some data in data base and when i run my application in simulator data is completely store in database but when i run this app on device nothing is store in database.
i am going through this code.
String url="http://68.20.66.178:8080/locationProvider/location.json";
GPRSCellInfo cellInfo = GPRSInfo.getCellInfo();
String event="";
//String requestString = "lat="+ parameters.lat + "&lon=" + parameters.lon;
String temp="cellid=" + GPRSInfo.getCellInfo().getCellId() + "&lac="
+ GPRSInfo.getCellInfo().getLAC() + "&mcc=" + cellInfo.getMCC()+ "&mnc="
+ cellInfo.getMNC() + "&imei=" + GPRSInfo.imeiToString(GPRSInfo.getIMEI(), false).trim() + "&lat="
+ parameters.lat + "&lon=" + parameters.lon
+ "&type=WORKFORCE&event" + event;
temp="imei="+imei1+"&cellid"+cellid+"&lac="+lac+"&mcc=" +mcc+"&mnc="+mnc+ "&lat="+ parameters.lat+"&lon=" + parameters.lon+"&type=WORKFORCE&event=" + event;
HttpConnectionUtil objConnectionUtil=new HttpConnectionUtil();
strRes1=objConnectionUtil.responseForGetRequest(url, temp);
System.out.println("Response1====="+strRes1);
Thread.sleep(delay);
ApplicationDescriptor current=ApplicationDescriptor.currentApplicationDescriptor();
current.setPowerOnBehavior(ApplicationDescriptor.DO_NOT_POWER_ON);
i am getting this value from simulator
URL==http://68.20.66.178:8080/locationProvider/location.json
[0.0] parameters==cellid=0&lac=0&mcc=0&mnc=0&imei=123456783648138&lat=0.0&lon=0.0&type=WORKFORCE&event
[0.0] response=={"lat":"0", "lon":"0", "provider":""}
[0.0] Response1====={"lat":"0", "lon":"0", "provider":""}
so where i making mistake please suggest me
Thanks
You say data is not stored in the database, but the only code provided is for making a web request. I assume the data in the web request is supposed to be stored in a database on the server.
Since your concern is mainly about the database, the first question is whether the request is getting to the server at all. Check your access logs, and see if anything matches up with what you expect coming from the device. If you see the appropriate entries in the access log, but nothing is getting stored in the database, then the problem is likely on the server.
However, this being BlackBerry, I suspect your problem is really with the connection appenders. This is asked frequently on stackoverflow:
BlackBerry simulator can connect to web service, but real device can't

Resources