| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_save_page_api.h" |
| 8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" |
| 9 #include "net/base/mock_host_resolver.h" | 11 #include "net/base/mock_host_resolver.h" |
| 10 | 12 |
| 11 class ExtensionSavePageApiTest : public ExtensionApiTest { | 13 class ExtensionSavePageApiTest : public ExtensionApiTest { |
| 12 public: | 14 public: |
| 13 // TODO(jcivelli): remove this once save-page APIs are no longer experimental. | 15 // TODO(jcivelli): remove this once save-page APIs are no longer experimental. |
| 14 virtual void SetUpCommandLine(CommandLine* command_line) { | 16 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 15 ExtensionApiTest::SetUpCommandLine(command_line); | 17 ExtensionApiTest::SetUpCommandLine(command_line); |
| 16 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 18 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 19 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
| 17 } | 20 } |
| 18 | 21 |
| 19 virtual void SetUpInProcessBrowserTestFixture() { | 22 virtual void SetUpInProcessBrowserTestFixture() { |
| 20 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 23 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 21 | 24 |
| 22 host_resolver()->AddRule("www.a.com", "127.0.0.1"); | 25 host_resolver()->AddRule("www.a.com", "127.0.0.1"); |
| 23 | 26 |
| 24 ASSERT_TRUE(StartTestServer()); | 27 ASSERT_TRUE(StartTestServer()); |
| 25 } | 28 } |
| 26 }; | 29 }; |
| 27 | 30 |
| 28 // Disabled on Linux http://crbug.com/98194 | 31 // Disabled on Linux http://crbug.com/98194 |
| 29 #if defined(OS_LINUX) | 32 #if defined(OS_LINUX) |
| 30 #define MAYBE_SavePageAsMHTML DISABLED_SavePageAsMHTML | 33 #define MAYBE_SavePageAsMHTML DISABLED_SavePageAsMHTML |
| 31 #else | 34 #else |
| 32 #define MAYBE_SavePageAsMHTML SavePageAsMHTML | 35 #define MAYBE_SavePageAsMHTML SavePageAsMHTML |
| 33 #endif // defined(OS_LINUX) | 36 #endif // defined(OS_LINUX) |
| 34 | 37 |
| 38 class SavePageAsMHTMLDelegate : public SavePageAsMHTMLFunction::TestDelegate { |
| 39 public: |
| 40 SavePageAsMHTMLDelegate() { |
| 41 SavePageAsMHTMLFunction::SetTestDelegate(this); |
| 42 } |
| 43 |
| 44 virtual ~SavePageAsMHTMLDelegate() { |
| 45 SavePageAsMHTMLFunction::SetTestDelegate(NULL); |
| 46 } |
| 47 |
| 48 virtual void OnTemporaryFileCreated(const FilePath& temp_file) OVERRIDE { |
| 49 temp_file_ = temp_file; |
| 50 } |
| 51 |
| 52 FilePath temp_file_; |
| 53 }; |
| 54 |
| 35 IN_PROC_BROWSER_TEST_F(ExtensionSavePageApiTest, MAYBE_SavePageAsMHTML) { | 55 IN_PROC_BROWSER_TEST_F(ExtensionSavePageApiTest, MAYBE_SavePageAsMHTML) { |
| 56 SavePageAsMHTMLDelegate delegate; |
| 36 ASSERT_TRUE(RunExtensionTest("save_page")) << message_; | 57 ASSERT_TRUE(RunExtensionTest("save_page")) << message_; |
| 58 ASSERT_FALSE(delegate.temp_file_.empty()); |
| 59 // Flush the file message loop to make sure the delete happens. |
| 60 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 61 ASSERT_FALSE(file_util::PathExists(delegate.temp_file_)); |
| 62 |
| 37 } | 63 } |
| OLD | NEW |