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

Side by Side Diff: base/shell_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « base/shell.cc ('k') | base/shutdown_callback.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2003-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15 //
16 // Shell functions
17
18 #include <shlobj.h>
19 #include <map>
20 #include "base/basictypes.h"
21 #include "omaha/base/dynamic_link_kernel32.h"
22 #include "omaha/base/file.h"
23 #include "omaha/base/reg_key.h"
24 #include "omaha/base/shell.h"
25 #include "omaha/base/system_info.h"
26 #include "omaha/base/utils.h"
27 #include "omaha/testing/unit_test.h"
28
29 namespace omaha {
30
31 TEST(ShellTest, ShellLink) {
32 if (IsTestRunByLocalSystem()) {
33 return;
34 }
35
36 CString desktop;
37 EXPECT_SUCCEEDED(GetFolderPath(CSIDL_DESKTOP, &desktop));
38 CString link(desktop + _T("\\Shell Unittest.lnk"));
39 CString install_dir;
40 ASSERT_SUCCEEDED(Shell::GetSpecialFolder(CSIDL_PROGRAM_FILES,
41 true,
42 &install_dir));
43 install_dir += _T("\\Shell Unittest");
44 CString exe = install_dir + _T("\\foo.bar.exe");
45 ASSERT_FALSE(File::Exists(link));
46 ASSERT_SUCCEEDED(Shell::CreateLink(exe,
47 link,
48 install_dir,
49 _T(""),
50 _T("Google Update Unit Test"),
51 'W',
52 HOTKEYF_ALT | HOTKEYF_CONTROL,
53 NULL));
54 ASSERT_TRUE(File::Exists(link));
55 ASSERT_SUCCEEDED(Shell::RemoveLink(link));
56 ASSERT_FALSE(File::Exists(link));
57 }
58
59 struct Folders {
60 DWORD csidl;
61 CString name;
62 };
63
64 TEST(ShellTest, GetSpecialFolder) {
65 Folders folders[] = {
66 { CSIDL_COMMON_APPDATA,
67 CString("C:\\Documents and Settings\\All Users\\Application Data") },
68 { CSIDL_FONTS,
69 CString("C:\\WINDOWS\\Fonts") },
70 { CSIDL_PROGRAM_FILES,
71 CString("C:\\Program Files") },
72 };
73
74 if (SystemInfo::IsRunningOnVistaOrLater()) {
75 folders[0].name = _T("C:\\ProgramData");
76 }
77
78 // Override the program files location, which changes for 32-bit processes
79 // running on 64-bit systems.
80 BOOL isWow64 = FALSE;
81 EXPECT_SUCCEEDED(Kernel32::IsWow64Process(GetCurrentProcess(), &isWow64));
82 if (isWow64) {
83 folders[2].name += _T(" (x86)");
84 }
85
86 for (size_t i = 0; i != arraysize(folders); ++i) {
87 CString folder_name;
88 EXPECT_SUCCEEDED(Shell::GetSpecialFolder(folders[i].csidl,
89 false,
90 &folder_name));
91 // This should work, but CmpHelperSTRCASEEQ is not overloaded for wchars.
92 // EXPECT_STRCASEEQ(folder_name, folders[i].name);
93 EXPECT_EQ(folder_name.CompareNoCase(folders[i].name), 0);
94 }
95 }
96
97 TEST(ShellTest, GetSpecialFolderKeywordsMapping) {
98 typedef std::map<CString, CString> mapping;
99 mapping folder_map;
100 ASSERT_SUCCEEDED(Shell::GetSpecialFolderKeywordsMapping(&folder_map));
101 }
102
103 } // namespace omaha
104
OLDNEW
« no previous file with comments | « base/shell.cc ('k') | base/shutdown_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698