diff options
Diffstat (limited to 'chrome/browser/gtk/view_id_util_browsertest.cc')
-rw-r--r-- | chrome/browser/gtk/view_id_util_browsertest.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/browser/gtk/view_id_util_browsertest.cc b/chrome/browser/gtk/view_id_util_browsertest.cc new file mode 100644 index 0000000..b647900 --- /dev/null +++ b/chrome/browser/gtk/view_id_util_browsertest.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2010 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 <gtk/gtk.h> + +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_window.h" +#include "chrome/browser/gtk/view_id_util.h" +#include "chrome/common/url_constants.h" +#include "chrome/test/in_process_browser_test.h" + +class ViewIDTest : public InProcessBrowserTest { + public: + ViewIDTest() : root_window_(NULL) {} + + void CheckViewID(ViewID id, bool should_have) { + if (!root_window_) + root_window_ = GTK_WIDGET(browser()->window()->GetNativeHandle()); + + ASSERT_TRUE(root_window_); + EXPECT_EQ(should_have, !!ViewIDUtil::GetWidget(root_window_, id)) + << " Failed id=" << id; + } + + private: + GtkWidget* root_window_; +}; + +IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) { + // Make sure FindBar is created to test + // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE. + browser()->ShowFindBar(); + + for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) { + // Extension shelf is being removed, http://crbug.com/25106. + if (i == VIEW_ID_DEV_EXTENSION_SHELF) + continue; + + // The following ids are used only in views implementation. + if (i == VIEW_ID_CONTENTS_SPLIT || + i == VIEW_ID_INFO_BAR_CONTAINER || + i == VIEW_ID_DOWNLOAD_SHELF || + i == VIEW_ID_BOOKMARK_BAR_ELEMENT || + i == VIEW_ID_TAB) { + continue; + } + + CheckViewID(static_cast<ViewID>(i), true); + } + + CheckViewID(VIEW_ID_PREDEFINED_COUNT, false); +} + +IN_PROC_BROWSER_TEST_F(ViewIDTest, Delegate) { + CheckViewID(VIEW_ID_TAB_0, true); + CheckViewID(VIEW_ID_TAB_1, false); + + browser()->OpenURL(GURL(chrome::kAboutBlankURL), GURL(), + NEW_BACKGROUND_TAB, PageTransition::TYPED); + + CheckViewID(VIEW_ID_TAB_0, true); + CheckViewID(VIEW_ID_TAB_1, true); +} |