1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/gtk/view_id_util.h"
11 #include "chrome/common/url_constants.h"
12 #include "chrome/test/base/in_process_browser_test.h"
14 using content::OpenURLParams
;
16 class ViewIDTest
: public InProcessBrowserTest
{
18 ViewIDTest() : root_window_(NULL
) {}
20 void CheckViewID(ViewID id
, bool should_have
) {
22 root_window_
= GTK_WIDGET(browser()->window()->GetNativeWindow());
24 ASSERT_TRUE(root_window_
);
25 EXPECT_EQ(should_have
, !!ViewIDUtil::GetWidget(root_window_
, id
))
26 << " Failed id=" << id
;
30 GtkWidget
* root_window_
;
33 IN_PROC_BROWSER_TEST_F(ViewIDTest
, Basic
) {
34 // Make sure FindBar is created to test
35 // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE.
36 chrome::ShowFindBar(browser());
38 for (int i
= VIEW_ID_TOOLBAR
; i
< VIEW_ID_PREDEFINED_COUNT
; ++i
) {
39 // The following ids are used only in views implementation.
40 if (i
== VIEW_ID_CONTENTS_SPLIT
||
41 i
== VIEW_ID_INFO_BAR_CONTAINER
||
42 i
== VIEW_ID_DEV_TOOLS_DOCKED
||
43 i
== VIEW_ID_DOWNLOAD_SHELF
||
44 i
== VIEW_ID_BOOKMARK_BAR_ELEMENT
||
46 i
== VIEW_ID_FEEDBACK_BUTTON
||
47 i
== VIEW_ID_SCRIPT_BUBBLE
||
48 i
== VIEW_ID_MIC_SEARCH_BUTTON
||
49 i
== VIEW_ID_TRANSLATE_BUTTON
) {
53 CheckViewID(static_cast<ViewID
>(i
), true);
56 CheckViewID(VIEW_ID_PREDEFINED_COUNT
, false);
59 IN_PROC_BROWSER_TEST_F(ViewIDTest
, Delegate
) {
60 CheckViewID(VIEW_ID_TAB_0
, true);
61 CheckViewID(VIEW_ID_TAB_1
, false);
63 browser()->OpenURL(OpenURLParams(GURL(content::kAboutBlankURL
),
65 NEW_BACKGROUND_TAB
, content::PAGE_TRANSITION_TYPED
,
68 CheckViewID(VIEW_ID_TAB_0
, true);
69 CheckViewID(VIEW_ID_TAB_1
, true);