An officer told Edinburgh Sheriff Court he saw O’Connor holding a piece of paper to his nose in the back of a car in Edinburgh city centre on May 14 last year.
O’Connor allegedly gave police the false name “Johnston” when questioned. But after beginning to spell the name out as “J . . . O . . . S”, he ran off, the court heard.
The striker was eventually caught after he ran about 300 metres, and was found shaking and “out of breath”, an officer told the court.
The 29-year-old is charged with possessing cocaine in three different locations in the Capital and obstructing police.
His defence agent, Liam O’Donnell, said his client was unlawfully arrested and told the court the evidence against him cannot be allowed.
Pc Andrew Morrow, 34, said he had been on patrol in George Street on the night of May 14, 2011.
He said he saw a man holding a rolled up piece of paper to his nose in the back of a white Land Rover.
Pc Morrow said: “There were four persons in the vehicle. A male was putting a piece of paper towards his nose.”
The officer then opened the door to the car, which was parked in Hope Street Lane.
He said: “At that time I believed the male was snorting cocaine or something along those lines.”
The man, whom he identified as O’Connor, appeared “nervous and distracted”, he said.
Pc Morrow said he saw a bag containing white powder and a rolled-up £20 note on the back seat. After speaking to another man in the car, he then chased O’Connor towards Rose Street before the footballer was stopped by another police officer.
“He was very nervous looking, he was out of breath, he appeared to be shaking,” Pc Morrow said.
Another officer, Pc Katherine Eager, had spoken to O’Connor while he was sitting in the Land Rover. She said O’Connor initially tried to give a false name, but fled after spelling it wrong.
Officers found a bag containing a white powder when they searched O’Connor’s trouser pocket. O’Connor is said by police to have said words to the effect of “that was put there”.
The footballer was arrested and taken to St Leonard’s police station, where another bag of white powder was found in another trouser pocket, the court heard.
The case, before Sheriff Derek McIntyre, is due to continue later this week.