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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 1021073002: <webview> Implement clear http cache API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error on mac/android: std::set initializer list makes them unhappy Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/apps/app_browsertest_util.h" 9 #include "chrome/browser/apps/app_browsertest_util.h"
10 #include "chrome/browser/chrome_content_browser_client.h" 10 #include "chrome/browser/chrome_content_browser_client.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 private: 251 private:
252 bool requested_; 252 bool requested_;
253 bool checked_; 253 bool checked_;
254 scoped_refptr<content::MessageLoopRunner> request_message_loop_runner_; 254 scoped_refptr<content::MessageLoopRunner> request_message_loop_runner_;
255 scoped_refptr<content::MessageLoopRunner> check_message_loop_runner_; 255 scoped_refptr<content::MessageLoopRunner> check_message_loop_runner_;
256 256
257 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); 257 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate);
258 }; 258 };
259 259
260 class MockWebViewGuestDelegate : public extensions::WebViewGuestDelegate {
261 public:
262 explicit MockWebViewGuestDelegate(extensions::WebViewGuest* web_view_guest)
263 : web_view_guest_(web_view_guest), clear_cache_called_(false) {}
264 ~MockWebViewGuestDelegate() override {}
265
266 // WebViewGuestDelegate implementation.
267 void ClearCache(base::Time remove_since,
268 const base::Closure& callback) override {
269 clear_cache_called_ = true;
270 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
271 }
272 bool HandleContextMenu(const content::ContextMenuParams& params) override {
273 return false;
274 }
275 void OnAttachWebViewHelpers(content::WebContents* contents) override {}
276 void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) override {}
277 void OnDidInitialize() override {}
278 void OnDocumentLoadedInFrame(
279 content::RenderFrameHost* render_frame_host) override {}
280 void OnGuestDestroyed() override {}
281 void OnShowContextMenu(
282 int request_id,
283 const WebViewGuestDelegate::MenuItemVector* items) override {}
284
285 bool clear_cache_called() { return clear_cache_called_; }
286
287 private:
288 extensions::WebViewGuest* web_view_guest_;
289 bool clear_cache_called_;
290
291 DISALLOW_COPY_AND_ASSIGN(MockWebViewGuestDelegate);
292 };
293
260 // This class intercepts download request from the guest. 294 // This class intercepts download request from the guest.
261 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { 295 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate {
262 public: 296 public:
263 explicit MockDownloadWebContentsDelegate( 297 explicit MockDownloadWebContentsDelegate(
264 content::WebContentsDelegate* orig_delegate) 298 content::WebContentsDelegate* orig_delegate)
265 : orig_delegate_(orig_delegate), 299 : orig_delegate_(orig_delegate),
266 waiting_for_decision_(false), 300 waiting_for_decision_(false),
267 expect_allow_(false), 301 expect_allow_(false),
268 decision_made_(false), 302 decision_made_(false),
269 last_download_allowed_(false) {} 303 last_download_allowed_(false) {}
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 726
693 ExtensionTestMessageListener test_run_listener("PASSED", false); 727 ExtensionTestMessageListener test_run_listener("PASSED", false);
694 test_run_listener.set_failure_message("FAILED"); 728 test_run_listener.set_failure_message("FAILED");
695 EXPECT_TRUE( 729 EXPECT_TRUE(
696 content::ExecuteScript( 730 content::ExecuteScript(
697 embedder_web_contents, 731 embedder_web_contents,
698 base::StringPrintf("startDenyTest('%s')", test_name.c_str()))); 732 base::StringPrintf("startDenyTest('%s')", test_name.c_str())));
699 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); 733 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied());
700 } 734 }
701 735
736 // Loads an app with a <webview> in it, returns once a guest is created.
702 void LoadAppWithGuest(const std::string& app_path) { 737 void LoadAppWithGuest(const std::string& app_path) {
703 ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED", 738 ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED",
704 false); 739 false);
705 launched_listener.set_failure_message("WebViewTest.FAILURE"); 740 launched_listener.set_failure_message("WebViewTest.FAILURE");
706 LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener); 741 LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener);
707 742
708 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); 743 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated();
709 } 744 }
710 745
711 void SendMessageToEmbedder(const std::string& message) { 746 void SendMessageToEmbedder(const std::string& message) {
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 if (base::win::GetVersion() <= base::win::VERSION_XP) 2351 if (base::win::GetVersion() <= base::win::VERSION_XP)
2317 return; 2352 return;
2318 #endif 2353 #endif
2319 2354
2320 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 2355 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
2321 ASSERT_TRUE(RunPlatformAppTestWithArg( 2356 ASSERT_TRUE(RunPlatformAppTestWithArg(
2322 "platform_apps/web_view/common", "cleardata")) 2357 "platform_apps/web_view/common", "cleardata"))
2323 << message_; 2358 << message_;
2324 } 2359 }
2325 2360
2361 IN_PROC_BROWSER_TEST_F(WebViewTest, ClearDataCache) {
2362 LoadAppWithGuest("web_view/clear_data_cache");
2363 content::WebContents* guest_web_contents = GetGuestWebContents();
2364 auto guest = extensions::WebViewGuest::FromWebContents(guest_web_contents);
2365 ASSERT_TRUE(guest);
2366 scoped_ptr<extensions::WebViewGuestDelegate> mock_web_view_guest_delegate(
2367 new MockWebViewGuestDelegate(guest));
2368 scoped_ptr<extensions::WebViewGuestDelegate> orig_web_view_guest_delegate =
2369 guest->SetDelegateForTesting(mock_web_view_guest_delegate.Pass());
2370
2371 ASSERT_TRUE(GetEmbedderWebContents());
2372 ExtensionTestMessageListener clear_data_done_listener(
2373 "WebViewTest.CLEAR_DATA_DONE", false);
2374 EXPECT_TRUE(content::ExecuteScript(
2375 GetEmbedderWebContents(), base::StringPrintf("testClearDataCache()")));
2376 EXPECT_TRUE(clear_data_done_listener.WaitUntilSatisfied());
2377
2378 // Reset delegate back to original once we're done mocking.
2379 mock_web_view_guest_delegate =
2380 guest->SetDelegateForTesting(orig_web_view_guest_delegate.Pass());
2381 }
2382
2326 // This test is disabled on Win due to being flaky. http://crbug.com/294592 2383 // This test is disabled on Win due to being flaky. http://crbug.com/294592
2327 #if defined(OS_WIN) 2384 #if defined(OS_WIN)
2328 #define MAYBE_ConsoleMessage DISABLED_ConsoleMessage 2385 #define MAYBE_ConsoleMessage DISABLED_ConsoleMessage
2329 #else 2386 #else
2330 #define MAYBE_ConsoleMessage ConsoleMessage 2387 #define MAYBE_ConsoleMessage ConsoleMessage
2331 #endif 2388 #endif
2332 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_ConsoleMessage) { 2389 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_ConsoleMessage) {
2333 ASSERT_TRUE(RunPlatformAppTestWithArg( 2390 ASSERT_TRUE(RunPlatformAppTestWithArg(
2334 "platform_apps/web_view/common", "console_messages")) 2391 "platform_apps/web_view/common", "console_messages"))
2335 << message_; 2392 << message_;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 // http://crbug.com/403325 2717 // http://crbug.com/403325
2661 #define MAYBE_WebViewInBackgroundPage \ 2718 #define MAYBE_WebViewInBackgroundPage \
2662 DISABLED_WebViewInBackgroundPage 2719 DISABLED_WebViewInBackgroundPage
2663 #else 2720 #else
2664 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage 2721 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage
2665 #endif 2722 #endif
2666 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { 2723 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) {
2667 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) 2724 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
2668 << message_; 2725 << message_;
2669 } 2726 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698