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

Side by Side Diff: chrome/browser/shell_integration_win_unittest.cc

Issue 2321453002: c/browser, c/common, components S-W: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/shell_integration_win.h" 5 #include "chrome/browser/shell_integration_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 }; 38 };
39 39
40 class ShellIntegrationWinMigrateShortcutTest : public testing::Test { 40 class ShellIntegrationWinMigrateShortcutTest : public testing::Test {
41 protected: 41 protected:
42 ShellIntegrationWinMigrateShortcutTest() {} 42 ShellIntegrationWinMigrateShortcutTest() {}
43 43
44 void SetUp() override { 44 void SetUp() override {
45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
46 46
47 // A path to a random target. 47 // A path to a random target.
48 base::CreateTemporaryFileInDir(temp_dir_.path(), &other_target_); 48 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &other_target_);
49 49
50 // This doesn't need to actually have a base name of "chrome.exe". 50 // This doesn't need to actually have a base name of "chrome.exe".
51 base::CreateTemporaryFileInDir(temp_dir_.path(), &chrome_exe_); 51 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &chrome_exe_);
52 52
53 chrome_app_id_ = 53 chrome_app_id_ =
54 ShellUtil::GetBrowserModelId(BrowserDistribution::GetDistribution(), 54 ShellUtil::GetBrowserModelId(BrowserDistribution::GetDistribution(),
55 true); 55 true);
56 56
57 base::FilePath default_user_data_dir; 57 base::FilePath default_user_data_dir;
58 chrome::GetDefaultUserDataDirectory(&default_user_data_dir); 58 chrome::GetDefaultUserDataDirectory(&default_user_data_dir);
59 base::FilePath default_profile_path = 59 base::FilePath default_profile_path =
60 default_user_data_dir.AppendASCII(chrome::kInitialProfile); 60 default_user_data_dir.AppendASCII(chrome::kInitialProfile);
61 non_default_user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("root")) 61 non_default_user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("root"))
(...skipping 17 matching lines...) Expand all
79 79
80 CreateShortcuts(); 80 CreateShortcuts();
81 } 81 }
82 82
83 // Creates a test shortcut corresponding to |shortcut_properties| and resets 83 // Creates a test shortcut corresponding to |shortcut_properties| and resets
84 // |shortcut_properties| after copying it to an internal structure for later 84 // |shortcut_properties| after copying it to an internal structure for later
85 // verification. 85 // verification.
86 void AddTestShortcutAndResetProperties( 86 void AddTestShortcutAndResetProperties(
87 base::win::ShortcutProperties* shortcut_properties) { 87 base::win::ShortcutProperties* shortcut_properties) {
88 ShortcutTestObject shortcut_test_object; 88 ShortcutTestObject shortcut_test_object;
89 base::FilePath shortcut_path = 89 base::FilePath shortcut_path = temp_dir_.GetPath().Append(
90 temp_dir_.path().Append(L"Shortcut " + 90 L"Shortcut " + base::IntToString16(shortcuts_.size()) +
91 base::IntToString16(shortcuts_.size()) + 91 installer::kLnkExt);
92 installer::kLnkExt);
93 shortcut_test_object.path = shortcut_path; 92 shortcut_test_object.path = shortcut_path;
94 shortcut_test_object.properties = *shortcut_properties; 93 shortcut_test_object.properties = *shortcut_properties;
95 shortcuts_.push_back(shortcut_test_object); 94 shortcuts_.push_back(shortcut_test_object);
96 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 95 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
97 shortcut_path, *shortcut_properties, 96 shortcut_path, *shortcut_properties,
98 base::win::SHORTCUT_CREATE_ALWAYS)); 97 base::win::SHORTCUT_CREATE_ALWAYS));
99 shortcut_properties->options = 0U; 98 shortcut_properties->options = 0U;
100 } 99 }
101 100
102 void CreateShortcuts() { 101 void CreateShortcuts() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }; 257 };
259 258
260 } // namespace 259 } // namespace
261 260
262 TEST_F(ShellIntegrationWinMigrateShortcutTest, ClearDualModeAndAdjustAppIds) { 261 TEST_F(ShellIntegrationWinMigrateShortcutTest, ClearDualModeAndAdjustAppIds) {
263 if (base::win::GetVersion() < base::win::VERSION_WIN7) 262 if (base::win::GetVersion() < base::win::VERSION_WIN7)
264 return; 263 return;
265 264
266 // 9 shortcuts should have their app id updated below and shortcut 11 should 265 // 9 shortcuts should have their app id updated below and shortcut 11 should
267 // be migrated away from dual_mode for a total of 10 shortcuts migrated. 266 // be migrated away from dual_mode for a total of 10 shortcuts migrated.
268 EXPECT_EQ(10, MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.path())); 267 EXPECT_EQ(10,
268 MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.GetPath()));
269 269
270 // Shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have had their app_id fixed. 270 // Shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have had their app_id fixed.
271 shortcuts_[1].properties.set_app_id(chrome_app_id_); 271 shortcuts_[1].properties.set_app_id(chrome_app_id_);
272 shortcuts_[3].properties.set_app_id(chrome_app_id_); 272 shortcuts_[3].properties.set_app_id(chrome_app_id_);
273 shortcuts_[4].properties.set_app_id(chrome_app_id_); 273 shortcuts_[4].properties.set_app_id(chrome_app_id_);
274 shortcuts_[5].properties.set_app_id(chrome_app_id_); 274 shortcuts_[5].properties.set_app_id(chrome_app_id_);
275 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_); 275 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_);
276 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_); 276 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_);
277 shortcuts_[8].properties.set_app_id( 277 shortcuts_[8].properties.set_app_id(
278 non_default_user_data_dir_and_profile_chrome_app_id_); 278 non_default_user_data_dir_and_profile_chrome_app_id_);
279 shortcuts_[9].properties.set_app_id(extension_app_id_); 279 shortcuts_[9].properties.set_app_id(extension_app_id_);
280 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_); 280 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_);
281 281
282 // No shortcut should still have the dual_mode property. 282 // No shortcut should still have the dual_mode property.
283 for (size_t i = 0; i < shortcuts_.size(); ++i) 283 for (size_t i = 0; i < shortcuts_.size(); ++i)
284 shortcuts_[i].properties.set_dual_mode(false); 284 shortcuts_[i].properties.set_dual_mode(false);
285 285
286 for (size_t i = 0; i < shortcuts_.size(); ++i) { 286 for (size_t i = 0; i < shortcuts_.size(); ++i) {
287 SCOPED_TRACE(i); 287 SCOPED_TRACE(i);
288 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties); 288 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties);
289 } 289 }
290 290
291 // Make sure shortcuts are not re-migrated. 291 // Make sure shortcuts are not re-migrated.
292 EXPECT_EQ(0, MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.path())); 292 EXPECT_EQ(0,
293 MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.GetPath()));
293 } 294 }
294 295
295 TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) { 296 TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
296 const base::string16 base_app_id( 297 const base::string16 base_app_id(
297 BrowserDistribution::GetDistribution()->GetBaseAppId()); 298 BrowserDistribution::GetDistribution()->GetBaseAppId());
298 299
299 // Empty profile path should get chrome::kBrowserAppID 300 // Empty profile path should get chrome::kBrowserAppID
300 base::FilePath empty_path; 301 base::FilePath empty_path;
301 EXPECT_EQ(base_app_id, GetAppModelIdForProfile(base_app_id, empty_path)); 302 EXPECT_EQ(base_app_id, GetAppModelIdForProfile(base_app_id, empty_path));
302 303
303 // Default profile path should get chrome::kBrowserAppID 304 // Default profile path should get chrome::kBrowserAppID
304 base::FilePath default_user_data_dir; 305 base::FilePath default_user_data_dir;
305 chrome::GetDefaultUserDataDirectory(&default_user_data_dir); 306 chrome::GetDefaultUserDataDirectory(&default_user_data_dir);
306 base::FilePath default_profile_path = 307 base::FilePath default_profile_path =
307 default_user_data_dir.AppendASCII(chrome::kInitialProfile); 308 default_user_data_dir.AppendASCII(chrome::kInitialProfile);
308 EXPECT_EQ(base_app_id, 309 EXPECT_EQ(base_app_id,
309 GetAppModelIdForProfile(base_app_id, default_profile_path)); 310 GetAppModelIdForProfile(base_app_id, default_profile_path));
310 311
311 // Non-default profile path should get chrome::kBrowserAppID joined with 312 // Non-default profile path should get chrome::kBrowserAppID joined with
312 // profile info. 313 // profile info.
313 base::FilePath profile_path(FILE_PATH_LITERAL("root")); 314 base::FilePath profile_path(FILE_PATH_LITERAL("root"));
314 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); 315 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd"));
315 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); 316 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test"));
316 EXPECT_EQ(base_app_id + L".udd.UserDataTest", 317 EXPECT_EQ(base_app_id + L".udd.UserDataTest",
317 GetAppModelIdForProfile(base_app_id, profile_path)); 318 GetAppModelIdForProfile(base_app_id, profile_path));
318 } 319 }
319 320
320 } // namespace win 321 } // namespace win
321 } // namespace shell_integration 322 } // namespace shell_integration
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux_unittest.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698