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" |
18 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 23 #if defined(OS_WIN) |
| 24 #include "chrome/installer/util/browser_distribution.h" |
| 25 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
23 #include "base/environment.h" | 26 #include "base/environment.h" |
24 #include "chrome/browser/shell_integration_linux.h" | 27 #include "chrome/browser/shell_integration_linux.h" |
25 #endif | 28 #endif |
26 | 29 |
27 #define FPL FILE_PATH_LITERAL | 30 #define FPL FILE_PATH_LITERAL |
28 | 31 |
29 using content::BrowserThread; | 32 using content::BrowserThread; |
30 | 33 |
31 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
32 namespace { | 35 namespace { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 test_cases[i].template_contents, | 357 test_cases[i].template_contents, |
355 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), | 358 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), |
356 GURL(test_cases[i].url), | 359 GURL(test_cases[i].url), |
357 "", | 360 "", |
358 FilePath(), | 361 FilePath(), |
359 ASCIIToUTF16(test_cases[i].title), | 362 ASCIIToUTF16(test_cases[i].title), |
360 test_cases[i].icon_name, | 363 test_cases[i].icon_name, |
361 FilePath())); | 364 FilePath())); |
362 } | 365 } |
363 } | 366 } |
| 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 } |
364 #endif | 395 #endif |
OLD | NEW |