| OLD | NEW |
| 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.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/web_applications/web_app.h" | 16 #include "chrome/browser/web_applications/web_app.h" |
| 17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/chrome_paths_internal.h" | |
| 19 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 21 |
| 23 #if defined(OS_WIN) | 22 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 24 #include "chrome/installer/util/browser_distribution.h" | |
| 25 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 26 #include "base/environment.h" | 23 #include "base/environment.h" |
| 27 #include "chrome/browser/shell_integration_linux.h" | 24 #include "chrome/browser/shell_integration_linux.h" |
| 28 #endif | 25 #endif |
| 29 | 26 |
| 30 #define FPL FILE_PATH_LITERAL | 27 #define FPL FILE_PATH_LITERAL |
| 31 | 28 |
| 32 using content::BrowserThread; | 29 using content::BrowserThread; |
| 33 | 30 |
| 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 31 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 35 namespace { | 32 namespace { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 test_cases[i].template_contents, | 354 test_cases[i].template_contents, |
| 358 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), | 355 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), |
| 359 GURL(test_cases[i].url), | 356 GURL(test_cases[i].url), |
| 360 "", | 357 "", |
| 361 FilePath(), | 358 FilePath(), |
| 362 ASCIIToUTF16(test_cases[i].title), | 359 ASCIIToUTF16(test_cases[i].title), |
| 363 test_cases[i].icon_name, | 360 test_cases[i].icon_name, |
| 364 FilePath())); | 361 FilePath())); |
| 365 } | 362 } |
| 366 } | 363 } |
| 367 #elif defined(OS_WIN) | |
| 368 TEST(ShellIntegrationTest, GetAppModelIdForProfileTest) { | |
| 369 const string16 base_app_id( | |
| 370 BrowserDistribution::GetDistribution()->GetBaseAppId()); | |
| 371 | |
| 372 // Empty profile path should get chrome::kBrowserAppID | |
| 373 FilePath empty_path; | |
| 374 EXPECT_EQ(base_app_id, | |
| 375 ShellIntegration::GetAppModelIdForProfile(base_app_id, empty_path)); | |
| 376 | |
| 377 // Default profile path should get chrome::kBrowserAppID | |
| 378 FilePath default_user_data_dir; | |
| 379 chrome::GetDefaultUserDataDirectory(&default_user_data_dir); | |
| 380 FilePath default_profile_path = | |
| 381 default_user_data_dir.AppendASCII(chrome::kInitialProfile); | |
| 382 EXPECT_EQ(base_app_id, | |
| 383 ShellIntegration::GetAppModelIdForProfile(base_app_id, | |
| 384 default_profile_path)); | |
| 385 | |
| 386 // Non-default profile path should get chrome::kBrowserAppID joined with | |
| 387 // profile info. | |
| 388 FilePath profile_path(FILE_PATH_LITERAL("root")); | |
| 389 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); | |
| 390 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); | |
| 391 EXPECT_EQ(base_app_id + L".udd.UserDataTest", | |
| 392 ShellIntegration::GetAppModelIdForProfile(base_app_id, | |
| 393 profile_path)); | |
| 394 } | |
| 395 #endif | 364 #endif |
| OLD | NEW |