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

Side by Side Diff: chrome/browser/extensions/ad_view_browsertest.cc

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 7 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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" 8 #include "content/test/net/url_request_prepackaged_interceptor.h"
9 #include "net/url_request/url_fetcher.h" 9 #include "net/url_request/url_fetcher.h"
10 10
11 class AdViewTest : public extensions::PlatformAppBrowserTest { 11 class AdViewTest : public extensions::PlatformAppBrowserTest {
12 protected: 12 protected:
13 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 13 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
14 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); 14 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
15 command_line->AppendSwitch(switches::kEnableAdview); 15 command_line->AppendSwitch(switches::kEnableAdview);
16 command_line->AppendSwitch(switches::kEnableAdviewSrcAttribute); 16 command_line->AppendSwitch(switches::kEnableAdviewSrcAttribute);
17 } 17 }
18 }; 18 };
19 19
20 // This test checks the "loadcommit" event is called when the page inside an 20 // This test checks the "loadcommit" event is called when the page inside an
21 // <adview> is loaded. 21 // <adview> is loaded.
22 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
23 // Very flaky on MacOS 10.8. 23 // Very flaky on MacOS 10.8.
24 #define MAYBE_LoadCommitEventIsCalled DISABLED_LoadCommitEventIsCalled 24 #define MAYBE_LoadCommitEventIsCalled DISABLED_LoadCommitEventIsCalled
25 #else 25 #else
26 #define MAYBE_LoadCommitEventIsCalled LoadCommitEventIsCalled 26 #define MAYBE_LoadCommitEventIsCalled LoadCommitEventIsCalled
27 #endif 27 #endif
28 IN_PROC_BROWSER_TEST_F(AdViewTest, MAYBE_LoadCommitEventIsCalled) { 28 IN_PROC_BROWSER_TEST_F(AdViewTest, MAYBE_LoadCommitEventIsCalled) {
29 ASSERT_TRUE(StartTestServer()); 29 ASSERT_TRUE(StartEmbeddedTestServer());
30 30
31 ASSERT_TRUE(RunPlatformAppTest( 31 ASSERT_TRUE(RunPlatformAppTest(
32 "platform_apps/ad_view/loadcommit_event")) << message_; 32 "platform_apps/ad_view/loadcommit_event")) << message_;
33 } 33 }
34 34
35 // This test checks the "loadabort" event is called when the "src" attribute 35 // This test checks the "loadabort" event is called when the "src" attribute
36 // of an <adview> is an invalid URL. 36 // of an <adview> is an invalid URL.
37 IN_PROC_BROWSER_TEST_F(AdViewTest, LoadAbortEventIsCalled) { 37 IN_PROC_BROWSER_TEST_F(AdViewTest, LoadAbortEventIsCalled) {
38 ASSERT_TRUE(StartTestServer()); 38 ASSERT_TRUE(StartEmbeddedTestServer());
39 39
40 ASSERT_TRUE(RunPlatformAppTest( 40 ASSERT_TRUE(RunPlatformAppTest(
41 "platform_apps/ad_view/loadabort_event")) << message_; 41 "platform_apps/ad_view/loadabort_event")) << message_;
42 } 42 }
43 43
44 // This test checks the page loaded inside an <adview> has the ability to 44 // This test checks the page loaded inside an <adview> has the ability to
45 // 1) receive "message" events from the application, and 2) use 45 // 1) receive "message" events from the application, and 2) use
46 // "window.postMessage" to post back a message to the application. 46 // "window.postMessage" to post back a message to the application.
47 #if defined(OS_WIN) 47 #if defined(OS_WIN)
48 // Flaky, or takes too long time on Win7. (http://crbug.com/230271) 48 // Flaky, or takes too long time on Win7. (http://crbug.com/230271)
49 #define MAYBE_CommitMessageFromAdNetwork DISABLED_CommitMessageFromAdNetwork 49 #define MAYBE_CommitMessageFromAdNetwork DISABLED_CommitMessageFromAdNetwork
50 #else 50 #else
51 #define MAYBE_CommitMessageFromAdNetwork CommitMessageFromAdNetwork 51 #define MAYBE_CommitMessageFromAdNetwork CommitMessageFromAdNetwork
52 #endif 52 #endif
53 IN_PROC_BROWSER_TEST_F(AdViewTest, MAYBE_CommitMessageFromAdNetwork) { 53 IN_PROC_BROWSER_TEST_F(AdViewTest, MAYBE_CommitMessageFromAdNetwork) {
54 ASSERT_TRUE(StartTestServer()); 54 ASSERT_TRUE(StartEmbeddedTestServer());
55 55
56 ASSERT_TRUE(RunPlatformAppTest( 56 ASSERT_TRUE(RunPlatformAppTest(
57 "platform_apps/ad_view/onloadcommit_ack")) << message_; 57 "platform_apps/ad_view/onloadcommit_ack")) << message_;
58 } 58 }
59 59
60 // This test checks the page running inside an <adview> has the ability to load 60 // This test checks the page running inside an <adview> has the ability to load
61 // and display an image inside an <iframe>. 61 // and display an image inside an <iframe>.
62 // Note: Disabled for initial checkin because the test depends on a binary 62 // Note: Disabled for initial checkin because the test depends on a binary
63 // file (image035.png) which the trybots don't process correctly when 63 // file (image035.png) which the trybots don't process correctly when
64 // first checked-in. 64 // first checked-in.
65 IN_PROC_BROWSER_TEST_F(AdViewTest, DISABLED_DisplayFirstAd) { 65 IN_PROC_BROWSER_TEST_F(AdViewTest, DISABLED_DisplayFirstAd) {
66 ASSERT_TRUE(StartTestServer()); 66 ASSERT_TRUE(StartEmbeddedTestServer());
67 67
68 ASSERT_TRUE(RunPlatformAppTest( 68 ASSERT_TRUE(RunPlatformAppTest(
69 "platform_apps/ad_view/display_first_ad")) << message_; 69 "platform_apps/ad_view/display_first_ad")) << message_;
70 } 70 }
71 71
72 // This test checks that <adview> attributes are also exposed as properties 72 // This test checks that <adview> attributes are also exposed as properties
73 // (with the same name and value). 73 // (with the same name and value).
74 IN_PROC_BROWSER_TEST_F(AdViewTest, PropertiesAreInSyncWithAttributes) { 74 IN_PROC_BROWSER_TEST_F(AdViewTest, PropertiesAreInSyncWithAttributes) {
75 ASSERT_TRUE(StartTestServer()); 75 ASSERT_TRUE(StartEmbeddedTestServer());
76 76
77 ASSERT_TRUE(RunPlatformAppTest( 77 ASSERT_TRUE(RunPlatformAppTest(
78 "platform_apps/ad_view/properties_exposed")) << message_; 78 "platform_apps/ad_view/properties_exposed")) << message_;
79 } 79 }
80 80
81 // This test checks an <adview> element has no behavior when the "adview" 81 // This test checks an <adview> element has no behavior when the "adview"
82 // permission is missing from the application manifest. 82 // permission is missing from the application manifest.
83 IN_PROC_BROWSER_TEST_F(AdViewTest, AdViewPermissionIsRequired) { 83 IN_PROC_BROWSER_TEST_F(AdViewTest, AdViewPermissionIsRequired) {
84 ASSERT_TRUE(StartTestServer()); 84 ASSERT_TRUE(StartEmbeddedTestServer());
85 85
86 ASSERT_TRUE(RunPlatformAppTest( 86 ASSERT_TRUE(RunPlatformAppTest(
87 "platform_apps/ad_view/permission_required")) << message_; 87 "platform_apps/ad_view/permission_required")) << message_;
88 } 88 }
89 89
90 // This test checks that 1) it is possible change the value of the "ad-network" 90 // This test checks that 1) it is possible change the value of the "ad-network"
91 // attribute of an <adview> element and 2) changing the value will reset the 91 // attribute of an <adview> element and 2) changing the value will reset the
92 // "src" attribute. 92 // "src" attribute.
93 IN_PROC_BROWSER_TEST_F(AdViewTest, ChangeAdNetworkValue) { 93 IN_PROC_BROWSER_TEST_F(AdViewTest, ChangeAdNetworkValue) {
94 ASSERT_TRUE(StartTestServer()); 94 ASSERT_TRUE(StartEmbeddedTestServer());
95 95
96 ASSERT_TRUE(RunPlatformAppTest( 96 ASSERT_TRUE(RunPlatformAppTest(
97 "platform_apps/ad_view/change_ad_network")) << message_; 97 "platform_apps/ad_view/change_ad_network")) << message_;
98 } 98 }
99 99
100 class AdViewNoSrcTest : public extensions::PlatformAppBrowserTest { 100 class AdViewNoSrcTest : public extensions::PlatformAppBrowserTest {
101 protected: 101 protected:
102 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 102 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
103 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); 103 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
104 command_line->AppendSwitch(switches::kEnableAdview); 104 command_line->AppendSwitch(switches::kEnableAdview);
105 //Note: The "kEnableAdviewSrcAttribute" flag is not here! 105 //Note: The "kEnableAdviewSrcAttribute" flag is not here!
106 } 106 }
107 }; 107 };
108 108
109 // This test checks an invalid "ad-network" value (i.e. not whitelisted) 109 // This test checks an invalid "ad-network" value (i.e. not whitelisted)
110 // is ignored. 110 // is ignored.
111 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, InvalidAdNetworkIsIgnored) { 111 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, InvalidAdNetworkIsIgnored) {
112 ASSERT_TRUE(StartTestServer()); 112 ASSERT_TRUE(StartEmbeddedTestServer());
113 113
114 ASSERT_TRUE(RunPlatformAppTest( 114 ASSERT_TRUE(RunPlatformAppTest(
115 "platform_apps/ad_view/invalid_ad_network")) << message_; 115 "platform_apps/ad_view/invalid_ad_network")) << message_;
116 } 116 }
117 117
118 // This test checks the "src" attribute is ignored when the 118 // This test checks the "src" attribute is ignored when the
119 // "kEnableAdviewSrcAttribute" is missing. 119 // "kEnableAdviewSrcAttribute" is missing.
120 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, EnableAdviewSrcAttributeFlagRequired) { 120 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, EnableAdviewSrcAttributeFlagRequired) {
121 ASSERT_TRUE(StartTestServer()); 121 ASSERT_TRUE(StartEmbeddedTestServer());
122 122
123 ASSERT_TRUE(RunPlatformAppTest( 123 ASSERT_TRUE(RunPlatformAppTest(
124 "platform_apps/ad_view/src_flag_required")) << message_; 124 "platform_apps/ad_view/src_flag_required")) << message_;
125 } 125 }
126 126
127 // This test checks 1) an <adview> works end-to-end (i.e. page is loaded) when 127 // This test checks 1) an <adview> works end-to-end (i.e. page is loaded) when
128 // using a whitelisted ad-network, and 2) the "src" attribute is never exposed 128 // using a whitelisted ad-network, and 2) the "src" attribute is never exposed
129 // to the application. 129 // to the application.
130 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, SrcNotExposed) { 130 IN_PROC_BROWSER_TEST_F(AdViewNoSrcTest, SrcNotExposed) {
131 base::FilePath file_path = test_data_dir_ 131 base::FilePath file_path = test_data_dir_
(...skipping 19 matching lines...) Expand all
151 protected: 151 protected:
152 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 152 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
153 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); 153 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
154 //Note: The "kEnableAdview" flag is not here! 154 //Note: The "kEnableAdview" flag is not here!
155 } 155 }
156 }; 156 };
157 157
158 // This test checks an <adview> element has no behavior when the "kEnableAdview" 158 // This test checks an <adview> element has no behavior when the "kEnableAdview"
159 // flag is missing. 159 // flag is missing.
160 IN_PROC_BROWSER_TEST_F(AdViewNotEnabledTest, EnableAdviewFlagRequired) { 160 IN_PROC_BROWSER_TEST_F(AdViewNotEnabledTest, EnableAdviewFlagRequired) {
161 ASSERT_TRUE(StartTestServer()); 161 ASSERT_TRUE(StartEmbeddedTestServer());
162 162
163 ASSERT_TRUE(RunPlatformAppTest( 163 ASSERT_TRUE(RunPlatformAppTest(
164 "platform_apps/ad_view/flag_required")) << message_; 164 "platform_apps/ad_view/flag_required")) << message_;
165 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698