| OLD | NEW |
| 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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 // the profile directory accordingly. | 886 // the profile directory accordingly. |
| 887 if (GetInstalledIEVersion() == IE_8) { | 887 if (GetInstalledIEVersion() == IE_8) { |
| 888 profile_path = GetProfilePath(kIEProfileName); | 888 profile_path = GetProfilePath(kIEProfileName); |
| 889 } else { | 889 } else { |
| 890 profile_path = GetIETemporaryFilesFolder(); | 890 profile_path = GetIETemporaryFilesFolder(); |
| 891 profile_path = profile_path.Append(L"Google Chrome Frame"); | 891 profile_path = profile_path.Append(L"Google Chrome Frame"); |
| 892 } | 892 } |
| 893 return profile_path; | 893 return profile_path; |
| 894 } | 894 } |
| 895 | 895 |
| 896 FilePath GetTestDataFolder() { |
| 897 FilePath test_dir; |
| 898 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); |
| 899 test_dir = test_dir.Append(FILE_PATH_LITERAL("chrome_frame")) |
| 900 .Append(FILE_PATH_LITERAL("test")) |
| 901 .Append(FILE_PATH_LITERAL("data")); |
| 902 return test_dir; |
| 903 } |
| 904 |
| 905 std::wstring GetPathFromUrl(const std::wstring& url) { |
| 906 string16 url16 = WideToUTF16(url); |
| 907 GURL gurl = GURL(url16); |
| 908 if (gurl.has_query()) { |
| 909 GURL::Replacements replacements; |
| 910 replacements.ClearQuery(); |
| 911 gurl = gurl.ReplaceComponents(replacements); |
| 912 } |
| 913 return UTF8ToWide(gurl.PathForRequest()); |
| 914 } |
| 915 |
| 916 std::wstring GetPathAndQueryFromUrl(const std::wstring& url) { |
| 917 string16 url16 = WideToUTF16(url); |
| 918 GURL gurl = GURL(url16); |
| 919 return UTF8ToWide(gurl.PathForRequest()); |
| 920 } |
| 921 |
| 922 bool AddCFMetaTag(std::string* html_data) { |
| 923 if (!html_data) { |
| 924 NOTREACHED(); |
| 925 return false; |
| 926 } |
| 927 size_t head = html_data->find("<head>"); |
| 928 if (head == std::string::npos) { |
| 929 // Add missing head section. |
| 930 size_t html = html_data->find("<html>"); |
| 931 EXPECT_NE(std::string::npos, html) << "Meta tag will not be injected " |
| 932 << "because the html tag could not be found"; |
| 933 if (html != std::string::npos) { |
| 934 html_data->insert(html + strlen("<html>"), "<head></head>"); |
| 935 head = html_data->find("<head>"); |
| 936 } |
| 937 } |
| 938 if (head != std::string::npos) { |
| 939 html_data->insert( |
| 940 head + strlen("<head>"), |
| 941 "<meta http-equiv=\"x-ua-compatible\" content=\"chrome=1\" />"); |
| 942 } |
| 943 return head != std::string::npos; |
| 944 } |
| 945 |
| 896 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c, | 946 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c, |
| 897 int repeat, simulate_input::Modifier mod) { | 947 int repeat, simulate_input::Modifier mod) { |
| 898 const unsigned int kInterval = 25; | 948 const unsigned int kInterval = 25; |
| 899 unsigned int next_delay = delay; | 949 unsigned int next_delay = delay; |
| 900 for (int i = 0; i < repeat; i++) { | 950 for (int i = 0; i < repeat; i++) { |
| 901 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 951 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( |
| 902 simulate_input::SendExtendedKey, c, mod), next_delay); | 952 simulate_input::SendExtendedKey, c, mod), next_delay); |
| 903 next_delay += kInterval; | 953 next_delay += kInterval; |
| 904 } | 954 } |
| 905 | 955 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 924 } | 974 } |
| 925 | 975 |
| 926 DLOG(INFO) << "Started crash_service.exe so you know if a test crashes!"; | 976 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 | 977 // This sleep is to ensure that the crash service is done initializing, i.e |
| 928 // the pipe creation, etc. | 978 // the pipe creation, etc. |
| 929 Sleep(500); | 979 Sleep(500); |
| 930 return crash_service; | 980 return crash_service; |
| 931 } | 981 } |
| 932 | 982 |
| 933 } // namespace chrome_frame_test | 983 } // namespace chrome_frame_test |
| OLD | NEW |