Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Sep 13 10:05:31 2012 +0000
Revision:
33:16126e029d58
Parent:
32:8ff0b67bb58c
Child:
34:d9e45aad85f2
Changed test framework.

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