| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/base_switches.h" | |
| 6 #include "base/command_line.h" | |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | |
| 8 #include "chrome/browser/extensions/extension_save_page_api.h" | |
| 9 #include "chrome/common/chrome_switches.h" | |
| 10 #include "chrome/test/base/ui_test_utils.h" | |
| 11 #include "net/base/mock_host_resolver.h" | |
| 12 | |
| 13 class ExtensionSavePageApiTest : public ExtensionApiTest { | |
| 14 public: | |
| 15 // TODO(jcivelli): remove this once save-page APIs are no longer experimental. | |
| 16 virtual void SetUpCommandLine(CommandLine* command_line) { | |
| 17 ExtensionApiTest::SetUpCommandLine(command_line); | |
| 18 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | |
| 19 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | |
| 20 } | |
| 21 | |
| 22 virtual void SetUpInProcessBrowserTestFixture() { | |
| 23 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | |
| 24 | |
| 25 host_resolver()->AddRule("www.a.com", "127.0.0.1"); | |
| 26 | |
| 27 ASSERT_TRUE(StartTestServer()); | |
| 28 } | |
| 29 }; | |
| 30 | |
| 31 // Disabled on Linux http://crbug.com/98194 | |
| 32 #if defined(OS_LINUX) | |
| 33 #define MAYBE_SavePageAsMHTML DISABLED_SavePageAsMHTML | |
| 34 #else | |
| 35 #define MAYBE_SavePageAsMHTML SavePageAsMHTML | |
| 36 #endif // defined(OS_LINUX) | |
| 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 | |
| 55 IN_PROC_BROWSER_TEST_F(ExtensionSavePageApiTest, MAYBE_SavePageAsMHTML) { | |
| 56 SavePageAsMHTMLDelegate delegate; | |
| 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 | |
| 63 } | |
| OLD | NEW |