Actress Jodie Foster testified Monday night and yesterday during closed proceedings in U.S. District Court in connection with the upcoming trial of John W. Hinckley Jr., accused of shooting President Reagan a year ago.

Hinckley, who allegedly planned the assault to impress Foster, attended the court sessions.

Foster's testimony was taken in a sixth-floor courtroom and, according to sources, was recorded on videotape. Federal court rules allow for such testimony to be taken if there is a likelihood that a witness will not be available for trial or if lawyers agree that the witness' appearance in the courtroom is unnecessary.

Law enforcement officials, who confiscated letters from Hinckley after his arrest, have indicated they believe Hinckley assaulted the president to win Foster's attention. Reagan's press secretary, a D.C. police officer and a U.S. Secret Service agent also were wounded in the attack, which occurred outside the Washington Hilton on March 30, l981.

Foster appeared in the courtroom with her Washington lawyers, Nathan Lewin and Jonathan Sallet. Her testimony will remain sealed unless it is presented at Hinckley's trial.

Government lawyers as well as attorneys for Hinckley were present during the proceedings and Foster was cross-examined, the sources said.

Judge Barrington D. Parker presided over the hearings. In a brief statement released yesterday from his chambers, Parker said that Foster "was called upon to identify and comment on various items of evidence."

Hinckley's trial has been delayed over the past several months after his defense lawyers successfully argued to Parker that certain statements Hinckley made and certain documents belonging to him should not be admitted at his trial because they were illegally obtained by law enforcement officials.

The government appealed that decision to the U.S. Court of Appeals where a three-judge panel eventually upheld Parker's ruling. Hinckley's trial has been further delayed because the government has asked the full 11-member appeals court to review the panel's decision.

Hinckley is being held at the Army stockade at Fort Meade, Md.