1 package com.android.bluetooth.tests; 2 3 import java.io.IOException; 4 import java.util.ArrayList; 5 6 import javax.obex.HeaderSet; 7 import javax.obex.ObexPacket; 8 import javax.obex.Operation; 9 10 import junit.framework.Assert; 11 12 import com.android.bluetooth.tests.TestSequencer.OPTYPE; 13 14 public class SeqStep { 15 /** 16 * Test step class to define the operations to be tested. 17 * Some of the data in these test steps will be modified during 18 * test - e.g. the HeaderSets will be modified to enable SRM 19 * and/or carry test information 20 */ 21 /* Operation type - Connect, Get, Put etc. */ 22 public OPTYPE mType; 23 /* The headers to send in the request - and validate on server side */ 24 public HeaderSet mReqHeaders = null; 25 /* The headers to send in the response - and validate on client side */ 26 public HeaderSet mResHeaders = null; 27 /* Use SRM */ 28 public boolean mUseSrm = false; 29 /* The amount of data to include in the body */ 30 public ObexTestParams mParams = null; 31 /* The offset into the data where the un-pause signal is to be sent */ 32 public int mUnPauseOffset = -1; 33 /* The offset into the data where the Abort request is to be sent */ 34 public int mAbortOffset = -1; 35 /* The side to perform Abort */ 36 public boolean mServerSideAbout = false; 37 /* The ID of the test step */ 38 private int mId; 39 40 public boolean mSetPathBackup = false; /* bit 0 in flags */ 41 public boolean mSetPathCreate = false; /* Inverse of bit 1 in flags */ 42 43 44 public ISeqStepValidator mValidator = null; 45 public ISeqStepAction mServerPreAction = null; 46 public ISeqStepAction mClientPostAction = null; 47 48 /* Arrays to hold expected sequence of request/response packets. */ 49 public ArrayList<ObexPacket> mRequestPackets = null; 50 public ArrayList<ObexPacket> mResponsePackets = null; 51 52 public int index = 0; /* requests with same index are executed in parallel 53 (without waiting for a response) */ 54 SeqStep(OPTYPE type)55 public SeqStep(OPTYPE type) { 56 mRequestPackets = new ArrayList<ObexPacket>(); 57 mResponsePackets = new ArrayList<ObexPacket>(); 58 mType = type; 59 } 60 validate(HeaderSet response, Operation op)61 public boolean validate(HeaderSet response, Operation op) throws IOException { 62 Assert.assertNotNull(mValidator); 63 return mValidator.validate(this, response, op); 64 } 65 serverPreAction(HeaderSet request, Operation op)66 public void serverPreAction(HeaderSet request, Operation op) throws IOException { 67 if(mServerPreAction != null) { 68 mServerPreAction.execute(this, request, op); 69 } 70 } 71 clientPostAction(HeaderSet response, Operation op)72 public void clientPostAction(HeaderSet response, Operation op) throws IOException { 73 if(mClientPostAction != null) { 74 mClientPostAction.execute(this, response, op); 75 } 76 } 77 78 79 /* TODO: Consider to build these automatically based on the operations 80 * to be performed. Validate using utility functions - not strict 81 * binary compare. 82 * 83 * OR simply remove!*/ addObexPacketSet(ObexPacket request, ObexPacket response)84 public void addObexPacketSet(ObexPacket request, ObexPacket response) { 85 mRequestPackets.add(request); 86 mResponsePackets.add(response); 87 } 88 } 89