Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Sep 13 08:21:25 2012 +0000
Revision:
32:8ff0b67bb58c
Parent:
27:0297dbc3252b
Child:
33:16126e029d58
Changing the framework slightly.

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 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 32:8ff0b67bb58c 11 _description = gTest10Description;
ashleymills 24:8f0f9551122a 12 }
ashleymills 24:8f0f9551122a 13
ashleymills 24:8f0f9551122a 14 virtual void setupTest() {
ashleymills 24:8f0f9551122a 15
ashleymills 24:8f0f9551122a 16
ashleymills 24:8f0f9551122a 17 }
ashleymills 24:8f0f9551122a 18
ashleymills 24:8f0f9551122a 19 virtual bool runTest() {
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 };