summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 04:47:34 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 04:47:34 +0000
commitbdd8a0844809ef88321f289382f19a12ef8fd2cc (patch)
tree2d39cca09ee5660d816bb00526ddf5727670b3be /chrome_frame
parent2e9f432fdf535d68e00dc2e28e78503646f5ca45 (diff)
downloadchromium_src-bdd8a0844809ef88321f289382f19a12ef8fd2cc.zip
chromium_src-bdd8a0844809ef88321f289382f19a12ef8fd2cc.tar.gz
chromium_src-bdd8a0844809ef88321f289382f19a12ef8fd2cc.tar.bz2
Add new SaveLinkAs test for chrome frame.
BUG=none TEST=none Patch from Mitchell Berkowitz <mberkowitz@chromium.org> Review URL: http://codereview.chromium.org/3310023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/data/save_as_context_menu.html8
-rw-r--r--chrome_frame/test/ui_test.cc75
2 files changed, 49 insertions, 34 deletions
diff --git a/chrome_frame/test/data/save_as_context_menu.html b/chrome_frame/test/data/save_as_context_menu.html
new file mode 100644
index 0000000..b127874
--- /dev/null
+++ b/chrome_frame/test/data/save_as_context_menu.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>Save As download test</title>
+ </head>
+ <body>
+ <a href="download_file.zip">Download a file</a>
+ </body>
+</html>
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index 418c0fa..44353e1 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -355,6 +355,42 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test {
EXPECT_CALL(acc_observer_, OnAccDocLoad(_)).Times(testing::AnyNumber());
}
+ // Common helper function for "Save xxx As" tests.
+ void DoSaveAsTest(const wchar_t* role, const wchar_t* menu_item_name,
+ const wchar_t* file_ext) {
+ server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
+ MockWindowObserver win_observer_mock;
+ InSequence expect_in_sequence_for_scope;
+
+ // Open 'Save As' dialog.
+ const char* kSaveDlgCaption = "Save As";
+ EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
+ .WillOnce(testing::DoAll(
+ WatchWindow(&win_observer_mock, kSaveDlgCaption),
+ AccRightClick(AccObjectMatcher(L"", role))));
+ EXPECT_CALL(acc_observer_, OnMenuPopup(_))
+ .WillOnce(AccLeftClick(AccObjectMatcher(menu_item_name)));
+
+ // Get safe download name using temporary file.
+ FilePath temp_file_path;
+ ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path));
+ ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
+ temp_file_path = temp_file_path.ReplaceExtension(file_ext);
+
+ AccObjectMatcher file_name_box(L"File name:", L"editable text");
+ EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
+ .WillOnce(testing::DoAll(
+ AccSendCharMessage(file_name_box, L'a'),
+ AccSetValue(file_name_box, temp_file_path.value()),
+ AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button"))));
+
+ EXPECT_CALL(win_observer_mock, OnWindowClose(_))
+ .WillOnce(CloseWhenFileSaved(&ie_mock_, temp_file_path, 5000));
+
+ LaunchIEAndNavigate(GetTestUrl(L"save_as_context_menu.html"));
+ ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
+ }
+
protected:
testing::NiceMock<MockAccEventObserver> acc_observer_;
};
@@ -461,41 +497,12 @@ TEST_F(ContextMenuTest, CFInspector) {
kChromeFrameLongNavigationTimeoutInSeconds * 2);
}
-TEST_F(ContextMenuTest, CFSaveAs) {
- server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
- MockWindowObserver win_observer_mock;
-
- InSequence expect_in_sequence_for_scope;
-
- // Open 'Save As' dialog.
- const char* kSaveDlgCaption = "Save As";
- EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
- .WillOnce(testing::DoAll(
- WatchWindow(&win_observer_mock, kSaveDlgCaption),
- OpenContextMenuAsync()));
- EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(AccLeftClick(AccObjectMatcher(L"Save as...")));
-
- // Get safe download name using temporary file.
- FilePath temp_file_path;
- ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path));
- temp_file_path = temp_file_path.ReplaceExtension(L".htm");
- ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
-
- EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
- .WillOnce(testing::DoAll(
- AccSendCharMessage(AccObjectMatcher(L"File name:", L"editable text"),
- L'a'),
- AccSetValue(AccObjectMatcher(L"File name:", L"editable text"),
- temp_file_path.value()),
- AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button"))));
-
- EXPECT_CALL(win_observer_mock, OnWindowClose(_))
- .WillOnce(CloseWhenFileSaved(&ie_mock_, temp_file_path, 5000));
+TEST_F(ContextMenuTest, CFSavePageAs) {
+ ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"", L"Save as...", L".html"));
+}
- LaunchIENavigateAndLoop(GetSimplePageUrl(),
- kChromeFrameLongNavigationTimeoutInSeconds * 2);
- ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
+TEST_F(ContextMenuTest, CFSaveLinkAs) {
+ ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"link", L"Save link as...", L".zip"));
}
// This tests that the about:version page can be opened via the CF context menu.