Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/extension_test_message_listener.h" | 5 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 6 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 6 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
| 8 #include "content/test/net/url_request_prepackaged_interceptor.h" | |
| 9 #include "net/url_request/url_fetcher.h" | |
| 10 | |
| 8 | 11 |
| 9 class AdViewTest : public extensions::PlatformAppBrowserTest { | 12 class AdViewTest : public extensions::PlatformAppBrowserTest { |
| 10 protected: | 13 protected: |
| 11 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 14 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 12 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 15 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 13 command_line->AppendSwitch(switches::kEnableAdview); | 16 command_line->AppendSwitch(switches::kEnableAdview); |
| 14 command_line->AppendSwitch(switches::kEnableAdviewSrcAttribute); | 17 command_line->AppendSwitch(switches::kEnableAdviewSrcAttribute); |
| 15 } | 18 } |
| 16 }; | 19 }; |
| 17 | 20 |
| 18 IN_PROC_BROWSER_TEST_F(AdViewTest, LoadEventIsCalled) { | 21 IN_PROC_BROWSER_TEST_F(AdViewTest, LoadCommitEventIsCalled) { |
|
benwells
2013/04/02 00:49:45
Where did all the comments go?
rpaquay
2013/04/02 16:44:47
I moved them in their respective "chrometest.js" f
benwells
2013/04/03 02:40:03
This is the first point of investigation for anyon
rpaquay
2013/04/03 18:30:05
Done.
| |
| 19 ASSERT_TRUE(StartTestServer()); | 22 ASSERT_TRUE(StartTestServer()); |
| 20 | 23 |
| 21 ExtensionTestMessageListener listener("guest-loaded", false); | 24 ASSERT_TRUE(RunPlatformAppTest( |
| 22 LoadAndLaunchPlatformApp("ad_view/load_event"); | 25 "platform_apps/ad_view/loadcommit_event")) << message_; |
| 23 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
| 24 } | 26 } |
| 25 | 27 |
| 26 IN_PROC_BROWSER_TEST_F(AdViewTest, AdNetworkIsLoaded) { | 28 IN_PROC_BROWSER_TEST_F(AdViewTest, LoadAbortEventIsCalled) { |
| 27 ASSERT_TRUE(StartTestServer()); | 29 ASSERT_TRUE(StartTestServer()); |
| 28 | 30 |
| 29 ExtensionTestMessageListener listener("ad-network-loaded", false); | 31 ASSERT_TRUE(RunPlatformAppTest( |
| 30 LoadAndLaunchPlatformApp("ad_view/ad_network_loaded"); | 32 "platform_apps/ad_view/loadabort_event")) << message_; |
| 31 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
| 32 } | 33 } |
| 33 | 34 |
| 34 // This test currently fails on trybots because it requires new binary file | 35 IN_PROC_BROWSER_TEST_F(AdViewTest, CommitMessageFromAdNetwork) { |
| 35 // (image315.png). The test will be enabled once the binary files are committed. | |
| 36 IN_PROC_BROWSER_TEST_F(AdViewTest, DISABLED_DisplayFirstAd) { | |
| 37 ASSERT_TRUE(StartTestServer()); | 36 ASSERT_TRUE(StartTestServer()); |
| 38 | 37 |
| 39 ExtensionTestMessageListener listener("ad-displayed", false); | 38 ASSERT_TRUE(RunPlatformAppTest( |
| 40 LoadAndLaunchPlatformApp("ad_view/display_first_ad"); | 39 "platform_apps/ad_view/onloadcommit_ack")) << message_; |
| 41 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
| 42 } | 40 } |
| 41 | |
| 42 IN_PROC_BROWSER_TEST_F(AdViewTest, DisplayFirstAd) { | |
| 43 ASSERT_TRUE(StartTestServer()); | |
| 44 | |
| 45 ASSERT_TRUE(RunPlatformAppTest( | |
| 46 "platform_apps/ad_view/display_first_ad")) << message_; | |
| 47 } | |
| 48 | |
| 49 IN_PROC_BROWSER_TEST_F(AdViewTest, PropertiesAreInSyncWithAttributes) { | |
| 50 ASSERT_TRUE(StartTestServer()); | |
| 51 | |
| 52 ASSERT_TRUE(RunPlatformAppTest( | |
| 53 "platform_apps/ad_view/properties_exposed")) << message_; | |
| 54 } | |
| 55 | |
| 56 IN_PROC_BROWSER_TEST_F(AdViewTest, AdViewPermissionIsRequired) { | |
| 57 ASSERT_TRUE(StartTestServer()); | |
| 58 | |
| 59 ASSERT_TRUE(RunPlatformAppTest( | |
| 60 "platform_apps/ad_view/permission_required")) << message_; | |
| 61 } | |
| 62 | |
| 63 IN_PROC_BROWSER_TEST_F(AdViewTest, ChangeAdNetworkValue) { | |
| 64 ASSERT_TRUE(StartTestServer()); | |
| 65 | |
| 66 ASSERT_TRUE(RunPlatformAppTest( | |
| 67 "platform_apps/ad_view/change_ad_network")) << message_; | |
| 68 } | |
| 69 | |
| 70 | |
| 71 class AdViewNoSrcTest : public extensions::PlatformAppBrowserTest { | |
| 72 protected: | |
| 73 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 74 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | |
| 75 command_line->AppendSwitch(switches::kEnableAdview); | |
| 76 //Note: The "kEnableAdviewSrcAttribute" flag is not here! | |
| 77 } | |
| 78 }; | |
| 79 | |
| 80 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, InvalidAdNetworkIsIgnored) { | |
| 81 ASSERT_TRUE(StartTestServer()); | |
| 82 | |
| 83 ASSERT_TRUE(RunPlatformAppTest( | |
| 84 "platform_apps/ad_view/invalid_ad_network")) << message_; | |
| 85 } | |
| 86 | |
| 87 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, EnableAdviewSrcAttributeFlagRequired) { | |
| 88 ASSERT_TRUE(StartTestServer()); | |
| 89 | |
| 90 ASSERT_TRUE(RunPlatformAppTest( | |
| 91 "platform_apps/ad_view/src_flag_required")) << message_; | |
| 92 } | |
| 93 | |
| 94 // This test checks an <adview> works end-to-end (i.e. page is loaded) when | |
| 95 // using a whitelisted ad-network. | |
| 96 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, SrcNotExposed) { | |
| 97 base::FilePath file_path = test_data_dir_ | |
| 98 .AppendASCII("platform_apps") | |
| 99 .AppendASCII("ad_view/src_not_exposed") | |
| 100 .AppendASCII("ad_network_fake_website.html"); | |
| 101 | |
| 102 // Note: The following URL is identical to the whitelisted url | |
| 103 // for "admob" (see ad_view.js). | |
| 104 GURL url = GURL("https://admob-sdk.doubleclick.net/chromeapps"); | |
| 105 std::string scheme = url.scheme(); | |
| 106 std::string hostname = url.host(); | |
| 107 | |
| 108 content::URLRequestPrepackagedInterceptor interceptor(scheme, hostname); | |
| 109 interceptor.SetResponse(url, file_path); | |
| 110 | |
| 111 ASSERT_TRUE(RunPlatformAppTest( | |
| 112 "platform_apps/ad_view/src_not_exposed")) << message_; | |
| 113 ASSERT_EQ(1, interceptor.GetHitCount()); | |
| 114 } | |
| 115 | |
| 116 | |
| 117 class AdViewNotEnabledTest : public extensions::PlatformAppBrowserTest { | |
| 118 protected: | |
| 119 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 120 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | |
| 121 //Note: The "kEnableAdview" flag is not here! | |
| 122 } | |
| 123 }; | |
| 124 | |
| 125 IN_PROC_BROWSER_TEST_F(AdViewNotEnabledTest, EnableAdviewFlagRequired) { | |
| 126 ASSERT_TRUE(StartTestServer()); | |
| 127 | |
| 128 ASSERT_TRUE(RunPlatformAppTest( | |
| 129 "platform_apps/ad_view/flag_required")) << message_; | |
| 130 } | |
| OLD | NEW |