A jury has heard claims that a man went "berserk" in a third floor flat and recklessly threw a hamster in a cage and other items out of the window.
Mr Thompson denied the charges at Dumfries Sheriff Court
Andrew Thompson, 20, of Oakfield Drive, Dumfries, denied committing the offence in October last year.
Sgt Alan Ross told Dumfries Sheriff Court he saw the animal's cage hit the pavement and crash onto the road.
He said police eventually got into the flat and subdued Mr Thompson with CS spray. The trial continues.
Acting Sgt Ross told the court he arrived at the flat in answer to a 999 call.
He said he saw a man shouting and swearing and throwing items out of the window.
At another window a woman was screaming for help and shouting that her baby was inside. She yelled at the officers: "He's got a knife. He's going to kill you."
However, it later emerged there was no baby in the flat and the child had been being looked after by the woman's mother.
Mr Thompson denied smashing items of furniture in the flat in Oakfield Drive and brandishing a knife.
He also denied throwing items including the hamster, a television and glass bottles out of the window which could have resulted in people being struck and injured.
He pleaded not guilty to assaulting a police officer and attempting to hit him with a glass bottle by throwing it at him from the window.