Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test10.h@27:0297dbc3252b, 2012-09-06 (annotated)
- Committer:
- ashleymills
- Date:
- Thu Sep 06 15:13:38 2012 +0000
- Revision:
- 27:0297dbc3252b
- Parent:
- 26:9eefab9e28df
- Child:
- 32:8ff0b67bb58c
Commended out dependency stuff. TestManager now prints numbers and descriptions of failed tests.
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 | 24:8f0f9551122a | 4 | |
ashleymills | 27:0297dbc3252b | 5 | static const char* gTest10Description = "Connects to internet and downloads 100 byte file."; |
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 | 24:8f0f9551122a | 10 | Test10(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) { |
ashleymills | 24:8f0f9551122a | 11 | } |
ashleymills | 24:8f0f9551122a | 12 | |
ashleymills | 24:8f0f9551122a | 13 | virtual void setupTest() { |
ashleymills | 24:8f0f9551122a | 14 | |
ashleymills | 24:8f0f9551122a | 15 | |
ashleymills | 24:8f0f9551122a | 16 | } |
ashleymills | 24:8f0f9551122a | 17 | |
ashleymills | 24:8f0f9551122a | 18 | virtual bool runTest() { |
ashleymills | 24:8f0f9551122a | 19 | HTTPClient http; |
ashleymills | 24:8f0f9551122a | 20 | char msgBuffer[125]; |
ashleymills | 24:8f0f9551122a | 21 | bool outcome = true; |
ashleymills | 24:8f0f9551122a | 22 | LOG("Description: %s",gTest10Description); |
ashleymills | 24:8f0f9551122a | 23 | LOG("Connecting to internet"); |
ashleymills | 24:8f0f9551122a | 24 | if(_modem->connect("internet","web","web")==0) { |
ashleymills | 24:8f0f9551122a | 25 | LOG("Connected to internet"); |
ashleymills | 24:8f0f9551122a | 26 | } else { |
ashleymills | 24:8f0f9551122a | 27 | LOG("Failed to connect to internet"); |
ashleymills | 24:8f0f9551122a | 28 | outcome = false; |
ashleymills | 24:8f0f9551122a | 29 | } |
ashleymills | 24:8f0f9551122a | 30 | |
ashleymills | 24:8f0f9551122a | 31 | LOG("Test %d, retrieving a 5MB file via HTTP.", _testCaseNumber); |
ashleymills | 24:8f0f9551122a | 32 | if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) { |
ashleymills | 24:8f0f9551122a | 33 | LOG("Got \"%s\"",msgBuffer); |
ashleymills | 24:8f0f9551122a | 34 | char c = 0; |
ashleymills | 24:8f0f9551122a | 35 | for(int i=0; i<100; i++) { |
ashleymills | 24:8f0f9551122a | 36 | if(msgBuffer[i]!=c) { |
ashleymills | 24:8f0f9551122a | 37 | LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]); |
ashleymills | 24:8f0f9551122a | 38 | outcome = false; |
ashleymills | 24:8f0f9551122a | 39 | break; |
ashleymills | 24:8f0f9551122a | 40 | } |
ashleymills | 24:8f0f9551122a | 41 | c++; |
ashleymills | 24:8f0f9551122a | 42 | if(c==256) |
ashleymills | 24:8f0f9551122a | 43 | c = 0; |
ashleymills | 24:8f0f9551122a | 44 | } |
ashleymills | 24:8f0f9551122a | 45 | } else { |
ashleymills | 24:8f0f9551122a | 46 | LOG("HTTP get failure"); |
ashleymills | 24:8f0f9551122a | 47 | outcome = false; |
ashleymills | 24:8f0f9551122a | 48 | } |
ashleymills | 24:8f0f9551122a | 49 | _modem->disconnect(); |
ashleymills | 24:8f0f9551122a | 50 | return outcome; |
ashleymills | 24:8f0f9551122a | 51 | } |
ashleymills | 24:8f0f9551122a | 52 | |
ashleymills | 24:8f0f9551122a | 53 | virtual void endTest() { |
ashleymills | 24:8f0f9551122a | 54 | |
ashleymills | 24:8f0f9551122a | 55 | } |
ashleymills | 24:8f0f9551122a | 56 | |
ashleymills | 24:8f0f9551122a | 57 | private: |
ashleymills | 24:8f0f9551122a | 58 | |
ashleymills | 23:408199b5d2cb | 59 | }; |