After you get an upgraded Portal Gun, you reach Test Chamber 12.
There is a pit with a floor in it that you can put a portal on. There is also a piece of wall above the pit that points at a ledge above you. Make a portal on the piece of wall that is sticking out, then make a portal of the other color on the floor below. Then fling yourself into the portal on the floor. You will end up on the ledge above.
From here, check which color of portal is on the floor, and make a portal of the other color on the piece of wall that is farther up. Fall into the floor portal and you will reach a third ledge.
This ledge has a big red button on it. There is a piece of wall nearby that points up at an angle. Check which color of portal is on the floor, then make a portal of the other color on the angled piece of wall. Drop down to the ledge that is labelled with two dots, then fall from there into the floor portal, and you will reach the top of the room.
Put a Cube on the Button
Pick up a cube, then go down to the lowest level, but don't try to fall through the floor portal. When you are on the floor, drop the cube into the portal. After that, go through the floor portal. Put the cube on the red button if it isn't there already.
Reach the Exit
Now that the cube is on the red button, drop down to the ledge that is labelled with two dots, then fall into the floor portal to reach the top of the room again. Enter the elevator to go to Test Chamber 13.