Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Sep 06 13:35:25 2012 +0000
Revision:
25:55b865c41f21
Parent:
24:8f0f9551122a
Child:
26:9eefab9e28df
Added descriptions for each test.

Who changed what in which revision?

UserRevisionLine numberNew 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 24:8f0f9551122a 5 static const char* gTest10Description = "Connects to internet and downloads 100 byte file.\0";
ashleymills 25:55b865c41f21 6
ashleymills 24:8f0f9551122a 7 class Test10 : public VodafoneTestCase {
ashleymills 24:8f0f9551122a 8 public:
ashleymills 24:8f0f9551122a 9 Test10(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
ashleymills 24:8f0f9551122a 10 }
ashleymills 24:8f0f9551122a 11
ashleymills 24:8f0f9551122a 12 virtual void setupTest() {
ashleymills 24:8f0f9551122a 13
ashleymills 24:8f0f9551122a 14
ashleymills 24:8f0f9551122a 15 }
ashleymills 24:8f0f9551122a 16
ashleymills 24:8f0f9551122a 17 virtual bool runTest() {
ashleymills 24:8f0f9551122a 18 HTTPClient http;
ashleymills 24:8f0f9551122a 19 char msgBuffer[125];
ashleymills 24:8f0f9551122a 20 bool outcome = true;
ashleymills 24:8f0f9551122a 21 LOG("Description: %s",gTest10Description);
ashleymills 24:8f0f9551122a 22 LOG("Connecting to internet");
ashleymills 24:8f0f9551122a 23 if(_modem->connect("internet","web","web")==0) {
ashleymills 24:8f0f9551122a 24 LOG("Connected to internet");
ashleymills 24:8f0f9551122a 25 } else {
ashleymills 24:8f0f9551122a 26 LOG("Failed to connect to internet");
ashleymills 24:8f0f9551122a 27 outcome = false;
ashleymills 24:8f0f9551122a 28 }
ashleymills 24:8f0f9551122a 29
ashleymills 24:8f0f9551122a 30 LOG("Test %d, retrieving a 5MB file via HTTP.", _testCaseNumber);
ashleymills 24:8f0f9551122a 31 if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) {
ashleymills 24:8f0f9551122a 32 LOG("Got \"%s\"",msgBuffer);
ashleymills 24:8f0f9551122a 33 char c = 0;
ashleymills 24:8f0f9551122a 34 for(int i=0; i<100; i++) {
ashleymills 24:8f0f9551122a 35 if(msgBuffer[i]!=c) {
ashleymills 24:8f0f9551122a 36 LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]);
ashleymills 24:8f0f9551122a 37 outcome = false;
ashleymills 24:8f0f9551122a 38 break;
ashleymills 24:8f0f9551122a 39 }
ashleymills 24:8f0f9551122a 40 c++;
ashleymills 24:8f0f9551122a 41 if(c==256)
ashleymills 24:8f0f9551122a 42 c = 0;
ashleymills 24:8f0f9551122a 43 }
ashleymills 24:8f0f9551122a 44 } else {
ashleymills 24:8f0f9551122a 45 LOG("HTTP get failure");
ashleymills 24:8f0f9551122a 46 outcome = false;
ashleymills 24:8f0f9551122a 47 }
ashleymills 24:8f0f9551122a 48 _modem->disconnect();
ashleymills 24:8f0f9551122a 49 return outcome;
ashleymills 24:8f0f9551122a 50 }
ashleymills 24:8f0f9551122a 51
ashleymills 24:8f0f9551122a 52 virtual void endTest() {
ashleymills 24:8f0f9551122a 53
ashleymills 24:8f0f9551122a 54 }
ashleymills 24:8f0f9551122a 55
ashleymills 24:8f0f9551122a 56 private:
ashleymills 24:8f0f9551122a 57
ashleymills 23:408199b5d2cb 58 };