Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test10.h@37:847f5f86e9ff, 2012-09-13 (annotated)
- Committer:
- ashleymills
- Date:
- Thu Sep 13 15:26:49 2012 +0000
- Revision:
- 37:847f5f86e9ff
- Parent:
- 34:d9e45aad85f2
- Child:
- 40:32b0558320ea
Test only constructed when executed. INCOMPLETE, need to change som e other stuff to reflect this.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 24:8f0f9551122a | 1 | #pragma once |
ashleymills | 24:8f0f9551122a | 2 | #include "VodafoneTestCase.h" |
ashleymills | 24:8f0f9551122a | 3 | #include "HTTPClient.h" |
ashleymills | 37:847f5f86e9ff | 4 | extern const char *gTest10Description; |
ashleymills | 24:8f0f9551122a | 5 | |
ashleymills | 27:0297dbc3252b | 6 | //const int gTest10Depends[] = {}; |
ashleymills | 25:55b865c41f21 | 7 | |
ashleymills | 24:8f0f9551122a | 8 | class Test10 : public VodafoneTestCase { |
ashleymills | 24:8f0f9551122a | 9 | public: |
ashleymills | 33:16126e029d58 | 10 | Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) { |
ashleymills | 32:8ff0b67bb58c | 11 | _description = gTest10Description; |
ashleymills | 33:16126e029d58 | 12 | _testCaseNumber = 10; |
ashleymills | 24:8f0f9551122a | 13 | } |
ashleymills | 24:8f0f9551122a | 14 | |
ashleymills | 24:8f0f9551122a | 15 | virtual void setupTest() { |
ashleymills | 24:8f0f9551122a | 16 | |
ashleymills | 24:8f0f9551122a | 17 | } |
ashleymills | 24:8f0f9551122a | 18 | |
ashleymills | 34:d9e45aad85f2 | 19 | virtual bool execute() { |
ashleymills | 24:8f0f9551122a | 20 | HTTPClient http; |
ashleymills | 24:8f0f9551122a | 21 | char msgBuffer[125]; |
ashleymills | 24:8f0f9551122a | 22 | bool outcome = true; |
ashleymills | 24:8f0f9551122a | 23 | LOG("Description: %s",gTest10Description); |
ashleymills | 24:8f0f9551122a | 24 | LOG("Connecting to internet"); |
ashleymills | 24:8f0f9551122a | 25 | if(_modem->connect("internet","web","web")==0) { |
ashleymills | 24:8f0f9551122a | 26 | LOG("Connected to internet"); |
ashleymills | 24:8f0f9551122a | 27 | } else { |
ashleymills | 24:8f0f9551122a | 28 | LOG("Failed to connect to internet"); |
ashleymills | 24:8f0f9551122a | 29 | outcome = false; |
ashleymills | 24:8f0f9551122a | 30 | } |
ashleymills | 24:8f0f9551122a | 31 | |
ashleymills | 24:8f0f9551122a | 32 | LOG("Test %d, retrieving a 5MB file via HTTP.", _testCaseNumber); |
ashleymills | 24:8f0f9551122a | 33 | if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) { |
ashleymills | 24:8f0f9551122a | 34 | LOG("Got \"%s\"",msgBuffer); |
ashleymills | 24:8f0f9551122a | 35 | char c = 0; |
ashleymills | 24:8f0f9551122a | 36 | for(int i=0; i<100; i++) { |
ashleymills | 24:8f0f9551122a | 37 | if(msgBuffer[i]!=c) { |
ashleymills | 24:8f0f9551122a | 38 | LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]); |
ashleymills | 24:8f0f9551122a | 39 | outcome = false; |
ashleymills | 24:8f0f9551122a | 40 | break; |
ashleymills | 24:8f0f9551122a | 41 | } |
ashleymills | 24:8f0f9551122a | 42 | c++; |
ashleymills | 24:8f0f9551122a | 43 | if(c==256) |
ashleymills | 24:8f0f9551122a | 44 | c = 0; |
ashleymills | 24:8f0f9551122a | 45 | } |
ashleymills | 24:8f0f9551122a | 46 | } else { |
ashleymills | 24:8f0f9551122a | 47 | LOG("HTTP get failure"); |
ashleymills | 24:8f0f9551122a | 48 | outcome = false; |
ashleymills | 24:8f0f9551122a | 49 | } |
ashleymills | 24:8f0f9551122a | 50 | _modem->disconnect(); |
ashleymills | 24:8f0f9551122a | 51 | return outcome; |
ashleymills | 24:8f0f9551122a | 52 | } |
ashleymills | 24:8f0f9551122a | 53 | |
ashleymills | 24:8f0f9551122a | 54 | virtual void endTest() { |
ashleymills | 24:8f0f9551122a | 55 | |
ashleymills | 24:8f0f9551122a | 56 | } |
ashleymills | 24:8f0f9551122a | 57 | |
ashleymills | 24:8f0f9551122a | 58 | private: |
ashleymills | 24:8f0f9551122a | 59 | |
ashleymills | 23:408199b5d2cb | 60 | }; |