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

Side by Side Diff: chrome_frame/test/chrome_frame_test_utils.cc

Issue 2822016: [chrome_frame] Refactor/merge IE no interference tests with other mock event ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.h ('k') | chrome_frame/test/data/anchor.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome_frame/test/chrome_frame_test_utils.h" 5 #include "chrome_frame/test/chrome_frame_test_utils.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlwin.h> 8 #include <atlwin.h>
9 #include <iepmapi.h> 9 #include <iepmapi.h>
10 #include <sddl.h> 10 #include <sddl.h>
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 AllowSetForegroundWindow(ASFW_ANY); 349 AllowSetForegroundWindow(ASFW_ANY);
350 350
351 HRESULT hr = S_OK; 351 HRESULT hr = S_OK;
352 DWORD cocreate_flags = CLSCTX_LOCAL_SERVER; 352 DWORD cocreate_flags = CLSCTX_LOCAL_SERVER;
353 chrome_frame_test::LowIntegrityToken token; 353 chrome_frame_test::LowIntegrityToken token;
354 // Vista has a bug which manifests itself when a medium integrity process 354 // Vista has a bug which manifests itself when a medium integrity process
355 // launches a COM server like IE which runs in protected mode due to UAC. 355 // launches a COM server like IE which runs in protected mode due to UAC.
356 // This causes the IWebBrowser2 interface which is returned to be useless, 356 // This causes the IWebBrowser2 interface which is returned to be useless,
357 // i.e it does not receive any events, etc. Our workaround for this is 357 // i.e it does not receive any events, etc. Our workaround for this is
358 // to impersonate a low integrity token and then launch IE. 358 // to impersonate a low integrity token and then launch IE.
359 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { 359 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA &&
360 GetInstalledIEVersion() == IE_7) {
360 // Create medium integrity browser that will launch IE broker. 361 // Create medium integrity browser that will launch IE broker.
361 ScopedComPtr<IWebBrowser2> medium_integrity_browser; 362 ScopedComPtr<IWebBrowser2> medium_integrity_browser;
362 hr = medium_integrity_browser.CreateInstance(CLSID_InternetExplorer, NULL, 363 hr = medium_integrity_browser.CreateInstance(CLSID_InternetExplorer, NULL,
363 CLSCTX_LOCAL_SERVER); 364 CLSCTX_LOCAL_SERVER);
364 if (FAILED(hr)) 365 if (FAILED(hr))
365 return hr; 366 return hr;
366 medium_integrity_browser->Quit(); 367 medium_integrity_browser->Quit();
367 // Broker remains alive. 368 // Broker remains alive.
368 if (!token.Impersonate()) { 369 if (!token.Impersonate()) {
369 hr = HRESULT_FROM_WIN32(GetLastError()); 370 hr = HRESULT_FROM_WIN32(GetLastError());
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 // the profile directory accordingly. 887 // the profile directory accordingly.
887 if (GetInstalledIEVersion() == IE_8) { 888 if (GetInstalledIEVersion() == IE_8) {
888 profile_path = GetProfilePath(kIEProfileName); 889 profile_path = GetProfilePath(kIEProfileName);
889 } else { 890 } else {
890 profile_path = GetIETemporaryFilesFolder(); 891 profile_path = GetIETemporaryFilesFolder();
891 profile_path = profile_path.Append(L"Google Chrome Frame"); 892 profile_path = profile_path.Append(L"Google Chrome Frame");
892 } 893 }
893 return profile_path; 894 return profile_path;
894 } 895 }
895 896
897 FilePath GetTestDataFolder() {
898 FilePath test_dir;
899 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir);
900 test_dir = test_dir.Append(FILE_PATH_LITERAL("chrome_frame"))
901 .Append(FILE_PATH_LITERAL("test"))
902 .Append(FILE_PATH_LITERAL("data"));
903 return test_dir;
904 }
905
906 std::wstring GetPathFromUrl(const std::wstring& url) {
907 string16 url16 = WideToUTF16(url);
908 GURL gurl = GURL(url16);
909 if (gurl.has_query()) {
910 GURL::Replacements replacements;
911 replacements.ClearQuery();
912 gurl = gurl.ReplaceComponents(replacements);
913 }
914 return UTF8ToWide(gurl.PathForRequest());
915 }
916
917 std::wstring GetPathAndQueryFromUrl(const std::wstring& url) {
918 string16 url16 = WideToUTF16(url);
919 GURL gurl = GURL(url16);
920 return UTF8ToWide(gurl.PathForRequest());
921 }
922
923 bool AddCFMetaTag(std::string* html_data) {
924 if (!html_data) {
925 NOTREACHED();
926 return false;
927 }
928 size_t head = html_data->find("<head>");
929 if (head == std::string::npos) {
930 // Add missing head section.
931 size_t html = html_data->find("<html>");
932 EXPECT_NE(std::string::npos, html) << "Meta tag will not be injected "
933 << "because the html tag could not be found";
934 if (html != std::string::npos) {
935 html_data->insert(html + strlen("<html>"), "<head></head>");
936 head = html_data->find("<head>");
937 }
938 }
939 if (head != std::string::npos) {
940 html_data->insert(
941 head + strlen("<head>"),
942 "<meta http-equiv=\"x-ua-compatible\" content=\"chrome=1\" />");
943 }
944 return head != std::string::npos;
945 }
946
896 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c, 947 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c,
897 int repeat, simulate_input::Modifier mod) { 948 int repeat, simulate_input::Modifier mod) {
898 const unsigned int kInterval = 25; 949 const unsigned int kInterval = 25;
899 unsigned int next_delay = delay; 950 unsigned int next_delay = delay;
900 for (int i = 0; i < repeat; i++) { 951 for (int i = 0; i < repeat; i++) {
901 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 952 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
902 simulate_input::SendExtendedKey, c, mod), next_delay); 953 simulate_input::SendExtendedKey, c, mod), next_delay);
903 next_delay += kInterval; 954 next_delay += kInterval;
904 } 955 }
905 956
(...skipping 18 matching lines...) Expand all
924 } 975 }
925 976
926 DLOG(INFO) << "Started crash_service.exe so you know if a test crashes!"; 977 DLOG(INFO) << "Started crash_service.exe so you know if a test crashes!";
927 // This sleep is to ensure that the crash service is done initializing, i.e 978 // This sleep is to ensure that the crash service is done initializing, i.e
928 // the pipe creation, etc. 979 // the pipe creation, etc.
929 Sleep(500); 980 Sleep(500);
930 return crash_service; 981 return crash_service;
931 } 982 }
932 983
933 } // namespace chrome_frame_test 984 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.h ('k') | chrome_frame/test/data/anchor.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698