summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_content_browser_client_browsertest.cc
diff options
context:
space:
mode:
authorcem.kocagil@gmail.com <cem.kocagil@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-19 18:46:42 +0000
committercem.kocagil@gmail.com <cem.kocagil@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-19 18:46:42 +0000
commit37e0cc31daf14a537322363b9ed507ae7b556cc7 (patch)
tree85716b72fb934be1960f08b498e7a087935c58b9 /chrome/browser/chrome_content_browser_client_browsertest.cc
parente81f50d15815595c79075a2ffc1d8179d103647a (diff)
downloadchromium_src-37e0cc31daf14a537322363b9ed507ae7b556cc7.zip
chromium_src-37e0cc31daf14a537322363b9ed507ae7b556cc7.tar.gz
chromium_src-37e0cc31daf14a537322363b9ed507ae7b556cc7.tar.bz2
Add reverse URL handler for shortening uber URLs
BUG=120493 TEST=Open the settings page. The address bar should show "chrome://settings". Click the "extensions" button on the left. The address bar should show "chrome://extensions". Click the "settings" button on the left, "show advanced settings", "content settings". The address bar should show "chrome://settings/content". Review URL: https://chromiumcodereview.appspot.com/10780013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_content_browser_client_browsertest.cc')
-rw-r--r--chrome/browser/chrome_content_browser_client_browsertest.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/chrome_content_browser_client_browsertest.cc b/chrome/browser/chrome_content_browser_client_browsertest.cc
new file mode 100644
index 0000000..b562838
--- /dev/null
+++ b/chrome/browser/chrome_content_browser_client_browsertest.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
+#include "googleurl/src/gurl.h"
+
+namespace content {
+
+class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
+ public:
+ // Returns the last committed navigation entry of the first tab. May be NULL
+ // if there is no such entry.
+ NavigationEntry* GetLastCommittedEntry() {
+ return chrome::GetTabContentsAt(browser(), 0)->web_contents()
+ ->GetController().GetLastCommittedEntry();
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, UberURLHandler) {
+ const GURL url1_short(std::string("chrome://settings/"));
+ const GURL url1_long(std::string("chrome://chrome/settings/"));
+
+ const GURL url2_short(std::string("chrome://settings/content"));
+ const GURL url2_long(std::string("chrome://chrome/settings/content"));
+
+ ui_test_utils::NavigateToURL(browser(), url1_short);
+ NavigationEntry* entry = GetLastCommittedEntry();
+
+ ASSERT_TRUE(entry != NULL);
+ EXPECT_EQ(url1_long, entry->GetURL());
+ EXPECT_EQ(url1_short, entry->GetVirtualURL());
+
+ ui_test_utils::NavigateToURL(browser(), url2_short);
+ entry = GetLastCommittedEntry();
+
+ ASSERT_TRUE(entry != NULL);
+ EXPECT_EQ(url2_long, entry->GetURL());
+ EXPECT_EQ(url2_short, entry->GetVirtualURL());
+}
+
+} // namespace content