| OLD | NEW |
| 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/banners/app_banner_data_fetcher.h" | 5 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 145 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 146 WebAppBannerCreatedDirect) { | 146 WebAppBannerCreatedDirect) { |
| 147 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_TYPED, | 147 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_TYPED, |
| 148 1, true); | 148 1, true); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // http://crbug.com/517307 | 151 // http://crbug.com/517307 |
| 152 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
| 153 #define MAYBE_WebAppBannerCreatedDirectSingle \ | 153 #define MAYBE_WebAppBannerCreatedDirectSingle \ |
| 154 DISABLED_WebAppBannerCreatedDirectSingle | 154 WebAppBannerCreatedDirectSingle |
| 155 #else | 155 #else |
| 156 #define MAYBE_WebAppBannerCreatedDirectSingle WebAppBannerCreatedDirectSingle | 156 #define MAYBE_WebAppBannerCreatedDirectSingle WebAppBannerCreatedDirectSingle |
| 157 #endif | 157 #endif |
| 158 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 158 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 159 MAYBE_WebAppBannerCreatedDirectSingle) { | 159 MAYBE_WebAppBannerCreatedDirectSingle) { |
| 160 AppBannerSettingsHelper::SetEngagementWeights(2, 1); | 160 AppBannerSettingsHelper::SetEngagementWeights(2, 1); |
| 161 RunBannerTest("/banners/manifest_test_page.html", | 161 RunBannerTest("/banners/manifest_test_page.html", |
| 162 ui::PAGE_TRANSITION_GENERATED, 0, true); | 162 ui::PAGE_TRANSITION_GENERATED, 0, true); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // http://crbug.com/517307 | 165 // http://crbug.com/517307 |
| 166 #if defined(OS_WIN) | 166 #if defined(OS_WIN) |
| 167 #define MAYBE_WebAppBannerCreatedDirectMultiple \ | 167 #define MAYBE_WebAppBannerCreatedDirectMultiple \ |
| 168 DISABLED_WebAppBannerCreatedDirectMultiple | 168 WebAppBannerCreatedDirectMultiple |
| 169 #else | 169 #else |
| 170 #define MAYBE_WebAppBannerCreatedDirectMultiple \ | 170 #define MAYBE_WebAppBannerCreatedDirectMultiple \ |
| 171 WebAppBannerCreatedDirectMultiple | 171 WebAppBannerCreatedDirectMultiple |
| 172 #endif | 172 #endif |
| 173 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 173 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 174 MAYBE_WebAppBannerCreatedDirectMultiple) { | 174 MAYBE_WebAppBannerCreatedDirectMultiple) { |
| 175 AppBannerSettingsHelper::SetEngagementWeights(0.5, 1); | 175 AppBannerSettingsHelper::SetEngagementWeights(0.5, 1); |
| 176 RunBannerTest("/banners/manifest_test_page.html", | 176 RunBannerTest("/banners/manifest_test_page.html", |
| 177 ui::PAGE_TRANSITION_GENERATED, 3, true); | 177 ui::PAGE_TRANSITION_GENERATED, 3, true); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // http://crbug.com/517307 | 180 // http://crbug.com/517307 |
| 181 #if defined(OS_WIN) | 181 #if defined(OS_WIN) |
| 182 #define MAYBE_WebAppBannerCreatedIndirect DISABLED_WebAppBannerCreatedIndirect | 182 #define MAYBE_WebAppBannerCreatedIndirect WebAppBannerCreatedIndirect |
| 183 #else | 183 #else |
| 184 #define MAYBE_WebAppBannerCreatedIndirect WebAppBannerCreatedIndirect | 184 #define MAYBE_WebAppBannerCreatedIndirect WebAppBannerCreatedIndirect |
| 185 #endif | 185 #endif |
| 186 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 186 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 187 MAYBE_WebAppBannerCreatedIndirect) { | 187 MAYBE_WebAppBannerCreatedIndirect) { |
| 188 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, | 188 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, |
| 189 1, true); | 189 1, true); |
| 190 } | 190 } |
| 191 | 191 |
| 192 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 192 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 193 WebAppBannerCreatedIndirectSingle) { | 193 WebAppBannerCreatedIndirectSingle) { |
| 194 AppBannerSettingsHelper::SetEngagementWeights(1, 3); | 194 AppBannerSettingsHelper::SetEngagementWeights(1, 3); |
| 195 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_RELOAD, | 195 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_RELOAD, |
| 196 0, true); | 196 0, true); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // http://crbug.com/517307 | 199 // http://crbug.com/517307 |
| 200 #if defined(OS_WIN) | 200 #if defined(OS_WIN) |
| 201 #define MAYBE_WebAppBannerCreatedIndirectMultiple \ | 201 #define MAYBE_WebAppBannerCreatedIndirectMultiple \ |
| 202 DISABLED_WebAppBannerCreatedIndirectMultiple | 202 WebAppBannerCreatedIndirectMultiple |
| 203 #else | 203 #else |
| 204 #define MAYBE_WebAppBannerCreatedIndirectMultiple \ | 204 #define MAYBE_WebAppBannerCreatedIndirectMultiple \ |
| 205 WebAppBannerCreatedIndirectMultiple | 205 WebAppBannerCreatedIndirectMultiple |
| 206 #endif | 206 #endif |
| 207 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 207 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 208 MAYBE_WebAppBannerCreatedIndirectMultiple) { | 208 MAYBE_WebAppBannerCreatedIndirectMultiple) { |
| 209 AppBannerSettingsHelper::SetEngagementWeights(1, 0.5); | 209 AppBannerSettingsHelper::SetEngagementWeights(1, 0.5); |
| 210 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, | 210 RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, |
| 211 3, true); | 211 3, true); |
| 212 } | 212 } |
| 213 | 213 |
| 214 // http://crbug.com/517307 | 214 // http://crbug.com/517307 |
| 215 #if defined(OS_WIN) | 215 #if defined(OS_WIN) |
| 216 #define MAYBE_WebAppBannerCreatedVarious DISABLED_WebAppBannerCreatedVarious | 216 #define MAYBE_WebAppBannerCreatedVarious WebAppBannerCreatedVarious |
| 217 #else | 217 #else |
| 218 #define MAYBE_WebAppBannerCreatedVarious WebAppBannerCreatedVarious | 218 #define MAYBE_WebAppBannerCreatedVarious WebAppBannerCreatedVarious |
| 219 #endif | 219 #endif |
| 220 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 220 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 221 MAYBE_WebAppBannerCreatedVarious) { | 221 MAYBE_WebAppBannerCreatedVarious) { |
| 222 AppBannerSettingsHelper::SetEngagementWeights(0.5, 0.25); | 222 AppBannerSettingsHelper::SetEngagementWeights(0.5, 0.25); |
| 223 | 223 |
| 224 std::string valid_page("/banners/manifest_test_page.html"); | 224 std::string valid_page("/banners/manifest_test_page.html"); |
| 225 GURL test_url = embedded_test_server()->GetURL(valid_page); | 225 GURL test_url = embedded_test_server()->GetURL(valid_page); |
| 226 content::WebContents* web_contents = | 226 content::WebContents* web_contents = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 ui::PAGE_TRANSITION_FORM_SUBMIT, false); | 260 ui::PAGE_TRANSITION_FORM_SUBMIT, false); |
| 261 | 261 |
| 262 // Add a direct nav on day 4 which should trigger the banner. | 262 // Add a direct nav on day 4 which should trigger the banner. |
| 263 LoadURLAndWaitForServiceWorker(test_url); | 263 LoadURLAndWaitForServiceWorker(test_url); |
| 264 RunFetcher(web_contents->GetURL(), std::string(), | 264 RunFetcher(web_contents->GetURL(), std::string(), |
| 265 ui::PAGE_TRANSITION_TYPED, true); | 265 ui::PAGE_TRANSITION_TYPED, true); |
| 266 } | 266 } |
| 267 | 267 |
| 268 // http://crbug.com/517307 | 268 // http://crbug.com/517307 |
| 269 #if defined(OS_WIN) | 269 #if defined(OS_WIN) |
| 270 #define MAYBE_WebAppBannerNoTypeInManifest DISABLED_WebAppBannerNoTypeInManifest | 270 #define MAYBE_WebAppBannerNoTypeInManifest WebAppBannerNoTypeInManifest |
| 271 #else | 271 #else |
| 272 #define MAYBE_WebAppBannerNoTypeInManifest WebAppBannerNoTypeInManifest | 272 #define MAYBE_WebAppBannerNoTypeInManifest WebAppBannerNoTypeInManifest |
| 273 #endif | 273 #endif |
| 274 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 274 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 275 MAYBE_WebAppBannerNoTypeInManifest) { | 275 MAYBE_WebAppBannerNoTypeInManifest) { |
| 276 RunBannerTest("/banners/manifest_no_type_test_page.html", | 276 RunBannerTest("/banners/manifest_no_type_test_page.html", |
| 277 ui::PAGE_TRANSITION_TYPED, 1, true); | 277 ui::PAGE_TRANSITION_TYPED, 1, true); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // http://crbug.com/517307 | 280 // http://crbug.com/517307 |
| 281 #if defined(OS_WIN) | 281 #if defined(OS_WIN) |
| 282 #define MAYBE_WebAppBannerNoTypeInManifestCapsExtension DISABLED_WebAppBannerNoT
ypeInManifestCapsExtension | 282 #define MAYBE_WebAppBannerNoTypeInManifestCapsExtension WebAppBannerNoTypeInMani
festCapsExtension |
| 283 #else | 283 #else |
| 284 #define MAYBE_WebAppBannerNoTypeInManifestCapsExtension WebAppBannerNoTypeInMani
festCapsExtension | 284 #define MAYBE_WebAppBannerNoTypeInManifestCapsExtension WebAppBannerNoTypeInMani
festCapsExtension |
| 285 #endif | 285 #endif |
| 286 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 286 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 287 MAYBE_WebAppBannerNoTypeInManifestCapsExtension) { | 287 MAYBE_WebAppBannerNoTypeInManifestCapsExtension) { |
| 288 RunBannerTest("/banners/manifest_no_type_caps_test_page.html", | 288 RunBannerTest("/banners/manifest_no_type_caps_test_page.html", |
| 289 ui::PAGE_TRANSITION_TYPED, 1, true); | 289 ui::PAGE_TRANSITION_TYPED, 1, true); |
| 290 } | 290 } |
| 291 | 291 |
| 292 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, PlayAppManifest) { | 292 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, PlayAppManifest) { |
| 293 std::string valid_page("/banners/play_app_test_page.html"); | 293 std::string valid_page("/banners/play_app_test_page.html"); |
| 294 GURL test_url = embedded_test_server()->GetURL(valid_page); | 294 GURL test_url = embedded_test_server()->GetURL(valid_page); |
| 295 content::WebContents* web_contents = | 295 content::WebContents* web_contents = |
| 296 browser()->tab_strip_model()->GetActiveWebContents(); | 296 browser()->tab_strip_model()->GetActiveWebContents(); |
| 297 | 297 |
| 298 // Native banners do not require the SW, so we can just load the URL. | 298 // Native banners do not require the SW, so we can just load the URL. |
| 299 ui_test_utils::NavigateToURL(browser(), test_url); | 299 ui_test_utils::NavigateToURL(browser(), test_url); |
| 300 std::string play_platform("play"); | 300 std::string play_platform("play"); |
| 301 RunFetcher(web_contents->GetURL(), play_platform, ui::PAGE_TRANSITION_TYPED, | 301 RunFetcher(web_contents->GetURL(), play_platform, ui::PAGE_TRANSITION_TYPED, |
| 302 false); | 302 false); |
| 303 | 303 |
| 304 // The logic to get the details for a play app banner are only on android | 304 // The logic to get the details for a play app banner are only on android |
| 305 // builds, so this test does not check that the banner is shown. | 305 // builds, so this test does not check that the banner is shown. |
| 306 } | 306 } |
| 307 | 307 |
| 308 // http://crbug.com/517307 | 308 // http://crbug.com/517307 |
| 309 #if defined(OS_WIN) | 309 #if defined(OS_WIN) |
| 310 #define MAYBE_NoManifest DISABLED_NoManifest | 310 #define MAYBE_NoManifest NoManifest |
| 311 #else | 311 #else |
| 312 #define MAYBE_NoManifest NoManifest | 312 #define MAYBE_NoManifest NoManifest |
| 313 #endif | 313 #endif |
| 314 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, MAYBE_NoManifest) { | 314 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, MAYBE_NoManifest) { |
| 315 RunBannerTest("/banners/no_manifest_test_page.html", | 315 RunBannerTest("/banners/no_manifest_test_page.html", |
| 316 ui::PAGE_TRANSITION_TYPED, 1, false); | 316 ui::PAGE_TRANSITION_TYPED, 1, false); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // http://crbug.com/517307 | 319 // http://crbug.com/517307 |
| 320 #if defined(OS_WIN) | 320 #if defined(OS_WIN) |
| 321 #define MAYBE_CancelBannerDirect DISABLED_CancelBannerDirect | 321 #define MAYBE_CancelBannerDirect CancelBannerDirect |
| 322 #else | 322 #else |
| 323 #define MAYBE_CancelBannerDirect CancelBannerDirect | 323 #define MAYBE_CancelBannerDirect CancelBannerDirect |
| 324 #endif | 324 #endif |
| 325 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 325 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 326 MAYBE_CancelBannerDirect) { | 326 MAYBE_CancelBannerDirect) { |
| 327 RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, | 327 RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, |
| 328 false); | 328 false); |
| 329 } | 329 } |
| 330 | 330 |
| 331 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, CancelBannerIndirect) { | 331 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, CancelBannerIndirect) { |
| 332 AppBannerSettingsHelper::SetEngagementWeights(1, 0.5); | 332 AppBannerSettingsHelper::SetEngagementWeights(1, 0.5); |
| 333 RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 3, | 333 RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 3, |
| 334 false); | 334 false); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // http://crbug.com/517307 | 337 // http://crbug.com/517307 |
| 338 #if defined(OS_WIN) | 338 #if defined(OS_WIN) |
| 339 #define MAYBE_PromptBanner DISABLED_PromptBanner | 339 #define MAYBE_PromptBanner PromptBanner |
| 340 #else | 340 #else |
| 341 #define MAYBE_PromptBanner PromptBanner | 341 #define MAYBE_PromptBanner PromptBanner |
| 342 #endif | 342 #endif |
| 343 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, MAYBE_PromptBanner) { | 343 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, MAYBE_PromptBanner) { |
| 344 RunBannerTest("/banners/prompt_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, | 344 RunBannerTest("/banners/prompt_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, |
| 345 true); | 345 true); |
| 346 } | 346 } |
| 347 | 347 |
| 348 // http://crbug.com/517307 | 348 // http://crbug.com/517307 |
| 349 #if defined(OS_WIN) | 349 #if defined(OS_WIN) |
| 350 #define MAYBE_PromptBannerInHandler DISABLED_PromptBannerInHandler | 350 #define MAYBE_PromptBannerInHandler PromptBannerInHandler |
| 351 #else | 351 #else |
| 352 #define MAYBE_PromptBannerInHandler PromptBannerInHandler | 352 #define MAYBE_PromptBannerInHandler PromptBannerInHandler |
| 353 #endif | 353 #endif |
| 354 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 354 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 355 MAYBE_PromptBannerInHandler) { | 355 MAYBE_PromptBannerInHandler) { |
| 356 RunBannerTest("/banners/prompt_in_handler_test_page.html", | 356 RunBannerTest("/banners/prompt_in_handler_test_page.html", |
| 357 ui::PAGE_TRANSITION_TYPED, 1, true); | 357 ui::PAGE_TRANSITION_TYPED, 1, true); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // http://crbug.com/517307 | 360 // http://crbug.com/517307 |
| 361 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 362 #define MAYBE_WebAppBannerInIFrame DISABLED_WebAppBannerInIFrame | 362 #define MAYBE_WebAppBannerInIFrame WebAppBannerInIFrame |
| 363 #else | 363 #else |
| 364 #define MAYBE_WebAppBannerInIFrame WebAppBannerInIFrame | 364 #define MAYBE_WebAppBannerInIFrame WebAppBannerInIFrame |
| 365 #endif | 365 #endif |
| 366 | 366 |
| 367 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, | 367 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, |
| 368 MAYBE_WebAppBannerInIFrame) { | 368 MAYBE_WebAppBannerInIFrame) { |
| 369 RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, | 369 RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, |
| 370 false); | 370 false); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace banners | 373 } // namespace banners |
| OLD | NEW |