Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: chrome/browser/ui/website_settings/permission_bubble_manager_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h" 10 #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Requests before the load event should be bundled into one bubble. 46 // Requests before the load event should be bundled into one bubble.
47 // http://crbug.com/512849 flaky 47 // http://crbug.com/512849 flaky
48 #if defined(OS_WIN) 48 #if defined(OS_WIN)
49 #define MAYBE_RequestsBeforeLoad DISABLED_RequestsBeforeLoad 49 #define MAYBE_RequestsBeforeLoad DISABLED_RequestsBeforeLoad
50 #else 50 #else
51 #define MAYBE_RequestsBeforeLoad RequestsBeforeLoad 51 #define MAYBE_RequestsBeforeLoad RequestsBeforeLoad
52 #endif 52 #endif
53 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, 53 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest,
54 MAYBE_RequestsBeforeLoad) { 54 MAYBE_RequestsBeforeLoad) {
55 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 55 ASSERT_TRUE(embedded_test_server()->Start());
56 56
57 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 57 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
58 browser(), 58 browser(),
59 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 59 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
60 1); 60 1);
61 WaitForPermissionBubble(); 61 WaitForPermissionBubble();
62 62
63 EXPECT_EQ(1, bubble_view()->show_count()); 63 EXPECT_EQ(1, bubble_view()->show_count());
64 EXPECT_EQ(2, bubble_view()->requests_count()); 64 EXPECT_EQ(2, bubble_view()->requests_count());
65 } 65 }
66 66
67 // Requests before the load should not be bundled with a request after the load. 67 // Requests before the load should not be bundled with a request after the load.
68 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, 68 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest,
69 RequestsBeforeAfterLoad) { 69 RequestsBeforeAfterLoad) {
70 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 70 ASSERT_TRUE(embedded_test_server()->Start());
71 71
72 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 72 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
73 browser(), 73 browser(),
74 embedded_test_server()->GetURL( 74 embedded_test_server()->GetURL(
75 "/permissions/requests-before-after-load.html"), 75 "/permissions/requests-before-after-load.html"),
76 1); 76 1);
77 WaitForPermissionBubble(); 77 WaitForPermissionBubble();
78 78
79 EXPECT_EQ(1, bubble_view()->show_count()); 79 EXPECT_EQ(1, bubble_view()->show_count());
80 EXPECT_EQ(1, bubble_view()->requests_count()); 80 EXPECT_EQ(1, bubble_view()->requests_count());
81 } 81 }
82 82
83 // Navigating twice to the same URL should be equivalent to refresh. This means 83 // Navigating twice to the same URL should be equivalent to refresh. This means
84 // showing the bubbles twice. 84 // showing the bubbles twice.
85 // http://crbug.com/512849 flaky 85 // http://crbug.com/512849 flaky
86 #if defined(OS_WIN) 86 #if defined(OS_WIN)
87 #define MAYBE_NavTwice DISABLED_NavTwice 87 #define MAYBE_NavTwice DISABLED_NavTwice
88 #else 88 #else
89 #define MAYBE_NavTwice NavTwice 89 #define MAYBE_NavTwice NavTwice
90 #endif 90 #endif
91 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, MAYBE_NavTwice) { 91 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, MAYBE_NavTwice) {
92 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 92 ASSERT_TRUE(embedded_test_server()->Start());
93 93
94 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 94 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
95 browser(), 95 browser(),
96 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 96 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
97 1); 97 1);
98 WaitForPermissionBubble(); 98 WaitForPermissionBubble();
99 99
100 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 100 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
101 browser(), 101 browser(),
102 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 102 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
103 1); 103 1);
104 WaitForPermissionBubble(); 104 WaitForPermissionBubble();
105 105
106 EXPECT_EQ(2, bubble_view()->show_count()); 106 EXPECT_EQ(2, bubble_view()->show_count());
107 EXPECT_EQ(4, bubble_view()->requests_count()); 107 EXPECT_EQ(4, bubble_view()->requests_count());
108 } 108 }
109 109
110 // Navigating twice to the same URL with a hash should be navigation within the 110 // Navigating twice to the same URL with a hash should be navigation within the
111 // page. This means the bubble is only shown once. 111 // page. This means the bubble is only shown once.
112 // http://crbug.com/512849 flaky 112 // http://crbug.com/512849 flaky
113 #if defined(OS_WIN) 113 #if defined(OS_WIN)
114 #define MAYBE_NavTwiceWithHash DISABLED_NavTwiceWithHash 114 #define MAYBE_NavTwiceWithHash DISABLED_NavTwiceWithHash
115 #else 115 #else
116 #define MAYBE_NavTwiceWithHash NavTwiceWithHash 116 #define MAYBE_NavTwiceWithHash NavTwiceWithHash
117 #endif 117 #endif
118 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, 118 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest,
119 MAYBE_NavTwiceWithHash) { 119 MAYBE_NavTwiceWithHash) {
120 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 120 ASSERT_TRUE(embedded_test_server()->Start());
121 121
122 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 122 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
123 browser(), 123 browser(),
124 embedded_test_server()->GetURL("/permissions/requests-before-load.html"), 124 embedded_test_server()->GetURL("/permissions/requests-before-load.html"),
125 1); 125 1);
126 WaitForPermissionBubble(); 126 WaitForPermissionBubble();
127 127
128 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 128 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
129 browser(), 129 browser(),
130 embedded_test_server()->GetURL( 130 embedded_test_server()->GetURL(
131 "/permissions/requests-before-load.html#0"), 131 "/permissions/requests-before-load.html#0"),
132 1); 132 1);
133 WaitForPermissionBubble(); 133 WaitForPermissionBubble();
134 134
135 EXPECT_EQ(1, bubble_view()->show_count()); 135 EXPECT_EQ(1, bubble_view()->show_count());
136 EXPECT_EQ(2, bubble_view()->requests_count()); 136 EXPECT_EQ(2, bubble_view()->requests_count());
137 } 137 }
138 138
139 // Bubble requests should be shown after in-page navigation. 139 // Bubble requests should be shown after in-page navigation.
140 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, InPageNavigation) { 140 IN_PROC_BROWSER_TEST_F(PermissionBubbleManagerBrowserTest, InPageNavigation) {
141 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 141 ASSERT_TRUE(embedded_test_server()->Start());
142 142
143 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 143 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
144 browser(), 144 browser(),
145 embedded_test_server()->GetURL("/empty.html"), 145 embedded_test_server()->GetURL("/empty.html"),
146 1); 146 1);
147 147
148 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 148 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
149 browser(), 149 browser(),
150 embedded_test_server()->GetURL("/empty.html#0"), 150 embedded_test_server()->GetURL("/empty.html#0"),
151 1); 151 1);
152 152
153 // Request 'geolocation' permission. 153 // Request 'geolocation' permission.
154 ExecuteScriptAndGetValue( 154 ExecuteScriptAndGetValue(
155 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(), 155 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
156 "navigator.geolocation.getCurrentPosition(function(){});"); 156 "navigator.geolocation.getCurrentPosition(function(){});");
157 WaitForPermissionBubble(); 157 WaitForPermissionBubble();
158 158
159 EXPECT_EQ(1, bubble_view()->show_count()); 159 EXPECT_EQ(1, bubble_view()->show_count());
160 EXPECT_EQ(1, bubble_view()->requests_count()); 160 EXPECT_EQ(1, bubble_view()->requests_count());
161 } 161 }
162 162
163 } // anonymous namespace 163 } // anonymous namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698