Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test10.cpp@44:6d0ac4747f5b, 2012-09-17 (annotated)
- Committer:
- ashleymills
- Date:
- Mon Sep 17 13:28:39 2012 +0000
- Revision:
- 44:6d0ac4747f5b
- Parent:
- 40:32b0558320ea
- Child:
- 53:54b2d3a0c7bf
Refactored names. Privatised virtuals to avoid bugs (bitten).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 40:32b0558320ea | 1 | #include "Test10.h" |
ashleymills | 40:32b0558320ea | 2 | |
ashleymills | 40:32b0558320ea | 3 | Test10::Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) { |
ashleymills | 40:32b0558320ea | 4 | _description = gTest10Description; |
ashleymills | 40:32b0558320ea | 5 | _testCaseNumber = 10; |
ashleymills | 40:32b0558320ea | 6 | } |
ashleymills | 40:32b0558320ea | 7 | |
ashleymills | 40:32b0558320ea | 8 | void Test10::setupTest() {} |
ashleymills | 40:32b0558320ea | 9 | |
ashleymills | 44:6d0ac4747f5b | 10 | bool Test10::executeTest() { |
ashleymills | 40:32b0558320ea | 11 | HTTPClient http; |
ashleymills | 40:32b0558320ea | 12 | char msgBuffer[125]; |
ashleymills | 40:32b0558320ea | 13 | bool outcome = true; |
ashleymills | 40:32b0558320ea | 14 | LOG("Description: %s",gTest10Description); |
ashleymills | 40:32b0558320ea | 15 | LOG("Connecting to internet"); |
ashleymills | 40:32b0558320ea | 16 | if(_modem->connect("internet","web","web")==0) { |
ashleymills | 40:32b0558320ea | 17 | LOG("Connected to internet"); |
ashleymills | 40:32b0558320ea | 18 | } else { |
ashleymills | 40:32b0558320ea | 19 | LOG("Failed to connect to internet"); |
ashleymills | 40:32b0558320ea | 20 | outcome = false; |
ashleymills | 40:32b0558320ea | 21 | } |
ashleymills | 40:32b0558320ea | 22 | |
ashleymills | 40:32b0558320ea | 23 | LOG("Doing HTTP GET for http://www.m2mthings.com/test100.txt"); |
ashleymills | 40:32b0558320ea | 24 | if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) { |
ashleymills | 40:32b0558320ea | 25 | LOG("Got buffer"); |
ashleymills | 40:32b0558320ea | 26 | char c = 0; |
ashleymills | 40:32b0558320ea | 27 | for(int i=0; i<100; i++) { |
ashleymills | 40:32b0558320ea | 28 | if(msgBuffer[i]!=c) { |
ashleymills | 40:32b0558320ea | 29 | LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]); |
ashleymills | 40:32b0558320ea | 30 | outcome = false; |
ashleymills | 40:32b0558320ea | 31 | break; |
ashleymills | 40:32b0558320ea | 32 | } |
ashleymills | 40:32b0558320ea | 33 | c++; |
ashleymills | 40:32b0558320ea | 34 | if(c==256) |
ashleymills | 40:32b0558320ea | 35 | c = 0; |
ashleymills | 40:32b0558320ea | 36 | } |
ashleymills | 40:32b0558320ea | 37 | LOG("All bytes match! PASS."); |
ashleymills | 40:32b0558320ea | 38 | } else { |
ashleymills | 40:32b0558320ea | 39 | LOG("HTTP get failure"); |
ashleymills | 40:32b0558320ea | 40 | outcome = false; |
ashleymills | 40:32b0558320ea | 41 | } |
ashleymills | 40:32b0558320ea | 42 | _modem->disconnect(); |
ashleymills | 40:32b0558320ea | 43 | return outcome; |
ashleymills | 40:32b0558320ea | 44 | } |
ashleymills | 40:32b0558320ea | 45 | |
ashleymills | 40:32b0558320ea | 46 | void Test10::endTest() { } |