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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 130773004: Start moving context menu code to RenderFrame. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 const extensions::CrxInstallerError& error) OVERRIDE { 317 const extensions::CrxInstallerError& error) OVERRIDE {
318 } 318 }
319 }; 319 };
320 320
321 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { 321 static DownloadManager* DownloadManagerForBrowser(Browser* browser) {
322 return BrowserContext::GetDownloadManager(browser->profile()); 322 return BrowserContext::GetDownloadManager(browser->profile());
323 } 323 }
324 324
325 class TestRenderViewContextMenu : public RenderViewContextMenu { 325 class TestRenderViewContextMenu : public RenderViewContextMenu {
326 public: 326 public:
327 TestRenderViewContextMenu(WebContents* web_contents, 327 TestRenderViewContextMenu(content::RenderFrameHost* render_frame_host,
328 const content::ContextMenuParams& params) 328 const content::ContextMenuParams& params)
329 : RenderViewContextMenu(web_contents, params) { 329 : RenderViewContextMenu(render_frame_host, params) {
330 } 330 }
331 virtual ~TestRenderViewContextMenu() {} 331 virtual ~TestRenderViewContextMenu() {}
332 332
333 private: 333 private:
334 virtual void PlatformInit() OVERRIDE {} 334 virtual void PlatformInit() OVERRIDE {}
335 virtual void PlatformCancel() OVERRIDE {} 335 virtual void PlatformCancel() OVERRIDE {}
336 virtual bool GetAcceleratorForCommandId(int, ui::Accelerator*) OVERRIDE { 336 virtual bool GetAcceleratorForCommandId(int, ui::Accelerator*) OVERRIDE {
337 return false; 337 return false;
338 } 338 }
339 339
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 // Try to download it via a context menu. 2326 // Try to download it via a context menu.
2327 scoped_ptr<content::DownloadTestObserver> waiter_context_menu( 2327 scoped_ptr<content::DownloadTestObserver> waiter_context_menu(
2328 new content::DownloadTestObserverTerminal( 2328 new content::DownloadTestObserverTerminal(
2329 DownloadManagerForBrowser(browser()), 1, 2329 DownloadManagerForBrowser(browser()), 1,
2330 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2330 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2331 content::ContextMenuParams context_menu_params; 2331 content::ContextMenuParams context_menu_params;
2332 context_menu_params.media_type = blink::WebContextMenuData::MediaTypeImage; 2332 context_menu_params.media_type = blink::WebContextMenuData::MediaTypeImage;
2333 context_menu_params.src_url = url; 2333 context_menu_params.src_url = url;
2334 context_menu_params.page_url = url; 2334 context_menu_params.page_url = url;
2335 TestRenderViewContextMenu menu( 2335 TestRenderViewContextMenu menu(
2336 browser()->tab_strip_model()->GetActiveWebContents(), 2336 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
2337 context_menu_params); 2337 context_menu_params);
2338 menu.Init(); 2338 menu.Init();
2339 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 0); 2339 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 0);
2340 waiter_context_menu->WaitForFinished(); 2340 waiter_context_menu->WaitForFinished();
2341 EXPECT_EQ( 2341 EXPECT_EQ(
2342 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2342 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2343 CheckDownloadStates(2, DownloadItem::COMPLETE); 2343 CheckDownloadStates(2, DownloadItem::COMPLETE);
2344 2344
2345 // Validate that the correct file was downloaded via the context menu. 2345 // Validate that the correct file was downloaded via the context menu.
2346 download_items.clear(); 2346 download_items.clear();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 2406
2407 // Try to download it via a context menu. 2407 // Try to download it via a context menu.
2408 scoped_ptr<content::DownloadTestObserver> waiter_context_menu( 2408 scoped_ptr<content::DownloadTestObserver> waiter_context_menu(
2409 new content::DownloadTestObserverTerminal( 2409 new content::DownloadTestObserverTerminal(
2410 DownloadManagerForBrowser(browser()), 1, 2410 DownloadManagerForBrowser(browser()), 1,
2411 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2411 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2412 content::ContextMenuParams context_menu_params; 2412 content::ContextMenuParams context_menu_params;
2413 context_menu_params.media_type = blink::WebContextMenuData::MediaTypeImage; 2413 context_menu_params.media_type = blink::WebContextMenuData::MediaTypeImage;
2414 context_menu_params.src_url = jpeg_url; 2414 context_menu_params.src_url = jpeg_url;
2415 context_menu_params.page_url = jpeg_url; 2415 context_menu_params.page_url = jpeg_url;
2416 TestRenderViewContextMenu menu(web_contents, context_menu_params); 2416 TestRenderViewContextMenu menu(web_contents->GetMainFrame(),
2417 context_menu_params);
2417 menu.Init(); 2418 menu.Init();
2418 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 0); 2419 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 0);
2419 waiter_context_menu->WaitForFinished(); 2420 waiter_context_menu->WaitForFinished();
2420 EXPECT_EQ( 2421 EXPECT_EQ(
2421 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2422 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2422 CheckDownloadStates(2, DownloadItem::COMPLETE); 2423 CheckDownloadStates(2, DownloadItem::COMPLETE);
2423 2424
2424 // Validate that the correct file was downloaded via the context menu. 2425 // Validate that the correct file was downloaded via the context menu.
2425 download_items.clear(); 2426 download_items.clear();
2426 GetDownloads(browser(), &download_items); 2427 GetDownloads(browser(), &download_items);
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 3243
3243 // No errors this time. The download should complete successfully. 3244 // No errors this time. The download should complete successfully.
3244 EXPECT_FALSE(completion_observer->IsFinished()); 3245 EXPECT_FALSE(completion_observer->IsFinished());
3245 completion_observer->StartObserving(); 3246 completion_observer->StartObserving();
3246 download->Resume(); 3247 download->Resume();
3247 completion_observer->WaitForFinished(); 3248 completion_observer->WaitForFinished();
3248 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); 3249 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState());
3249 3250
3250 EXPECT_FALSE(DidShowFileChooser()); 3251 EXPECT_FALSE(DidShowFileChooser());
3251 } 3252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698