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

Side by Side Diff: chrome/browser/extensions/api/page_capture/page_capture_apitest.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: rebase Created 7 years, 5 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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h" 7 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "net/dns/mock_host_resolver.h" 11 #include "net/dns/mock_host_resolver.h"
12 12
13 using extensions::PageCaptureSaveAsMHTMLFunction; 13 using extensions::PageCaptureSaveAsMHTMLFunction;
14 14
15 class ExtensionPageCaptureApiTest : public ExtensionApiTest { 15 class ExtensionPageCaptureApiTest : public ExtensionApiTest {
16 public: 16 public:
17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
18 ExtensionApiTest::SetUpCommandLine(command_line); 18 ExtensionApiTest::SetUpCommandLine(command_line);
19 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); 19 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
20 } 20 }
21
22 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
23 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
24
25 host_resolver()->AddRule("www.a.com", "127.0.0.1");
26
27 ASSERT_TRUE(StartTestServer());
28 }
29 }; 21 };
30 22
31 // Disabled on Linux http://crbug.com/98194
32 #if defined(OS_LINUX)
33 #define MAYBE_SaveAsMHTML DISABLED_SaveAsMHTML
34 #else
35 #define MAYBE_SaveAsMHTML SaveAsMHTML
36 #endif // defined(OS_LINUX)
37
38 class PageCaptureSaveAsMHTMLDelegate 23 class PageCaptureSaveAsMHTMLDelegate
39 : public PageCaptureSaveAsMHTMLFunction::TestDelegate { 24 : public PageCaptureSaveAsMHTMLFunction::TestDelegate {
40 public: 25 public:
41 PageCaptureSaveAsMHTMLDelegate() { 26 PageCaptureSaveAsMHTMLDelegate() {
42 PageCaptureSaveAsMHTMLFunction::SetTestDelegate(this); 27 PageCaptureSaveAsMHTMLFunction::SetTestDelegate(this);
43 } 28 }
44 29
45 virtual ~PageCaptureSaveAsMHTMLDelegate() { 30 virtual ~PageCaptureSaveAsMHTMLDelegate() {
46 PageCaptureSaveAsMHTMLFunction::SetTestDelegate(NULL); 31 PageCaptureSaveAsMHTMLFunction::SetTestDelegate(NULL);
47 } 32 }
48 33
49 virtual void OnTemporaryFileCreated( 34 virtual void OnTemporaryFileCreated(
50 const base::FilePath& temp_file) OVERRIDE { 35 const base::FilePath& temp_file) OVERRIDE {
51 temp_file_ = temp_file; 36 temp_file_ = temp_file;
52 } 37 }
53 38
54 base::FilePath temp_file_; 39 base::FilePath temp_file_;
55 }; 40 };
56 41
57 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, MAYBE_SaveAsMHTML) { 42 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, SaveAsMHTML) {
43 host_resolver()->AddRule("www.a.com", "127.0.0.1");
44 ASSERT_TRUE(StartEmbeddedTestServer());
58 PageCaptureSaveAsMHTMLDelegate delegate; 45 PageCaptureSaveAsMHTMLDelegate delegate;
59 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; 46 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
60 ASSERT_FALSE(delegate.temp_file_.empty()); 47 ASSERT_FALSE(delegate.temp_file_.empty());
61 // Flush the message loops to make sure the delete happens. 48 // Flush the message loops to make sure the delete happens.
62 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 49 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
63 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 50 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
64 ASSERT_FALSE(file_util::PathExists(delegate.temp_file_)); 51 ASSERT_FALSE(file_util::PathExists(delegate.temp_file_));
65 } 52 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/i18n/i18n_apitest.cc ('k') | chrome/browser/extensions/api/permissions/permissions_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698