Merge change 23647 into eclair

* changes:
  Add a test case in browser to measure the power usage of loading a web page
diff --git a/src/com/android/browser/TitleBarSet.java b/src/com/android/browser/TitleBarSet.java
index 4bd3fd8..873f40b 100644
--- a/src/com/android/browser/TitleBarSet.java
+++ b/src/com/android/browser/TitleBarSet.java
@@ -181,10 +181,12 @@
      * Remove the tab at the given position.
      */
     /* package */ void removeTab(int position) {
+        int selection = getSelectedItemPosition();
         mTitleBars.remove(position);
         mCount--;
         // Need to refresh our list
         setAdapter(mTitleAdapter);
+        setCurrentTab(selection);
     }
 
     /**
@@ -206,6 +208,7 @@
      * Change to the tab at the new position.
      */
     /* package */ void setCurrentTab(int position) {
+        if (position < 0 || position >= mCount) return;
         mIgnoreSelectedListener = true;
         setSelection(position);
         mIgnoreSelectedListener = false;