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/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/scoped_temp_dir.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 "chrome/common/chrome_paths_internal.h" |
19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const char kTemplateFilename[] = "chromium-browser.desktop"; | 77 const char kTemplateFilename[] = "chromium-browser.desktop"; |
78 #endif | 78 #endif |
79 | 79 |
80 const char kTestData1[] = "a magical testing string"; | 80 const char kTestData1[] = "a magical testing string"; |
81 const char kTestData2[] = "a different testing string"; | 81 const char kTestData2[] = "a different testing string"; |
82 | 82 |
83 MessageLoop message_loop; | 83 MessageLoop message_loop; |
84 content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop); | 84 content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop); |
85 | 85 |
86 { | 86 { |
87 ScopedTempDir temp_dir; | 87 base::ScopedTempDir temp_dir; |
88 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 88 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
89 | 89 |
90 MockEnvironment env; | 90 MockEnvironment env; |
91 env.Set("XDG_DATA_HOME", temp_dir.path().value()); | 91 env.Set("XDG_DATA_HOME", temp_dir.path().value()); |
92 ASSERT_TRUE(file_util::WriteFile( | 92 ASSERT_TRUE(file_util::WriteFile( |
93 temp_dir.path().AppendASCII(kTemplateFilename), | 93 temp_dir.path().AppendASCII(kTemplateFilename), |
94 kTestData1, strlen(kTestData1))); | 94 kTestData1, strlen(kTestData1))); |
95 std::string contents; | 95 std::string contents; |
96 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, | 96 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, |
97 &contents)); | 97 &contents)); |
98 EXPECT_EQ(kTestData1, contents); | 98 EXPECT_EQ(kTestData1, contents); |
99 } | 99 } |
100 | 100 |
101 { | 101 { |
102 ScopedTempDir temp_dir; | 102 base::ScopedTempDir temp_dir; |
103 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 103 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
104 | 104 |
105 MockEnvironment env; | 105 MockEnvironment env; |
106 env.Set("XDG_DATA_DIRS", temp_dir.path().value()); | 106 env.Set("XDG_DATA_DIRS", temp_dir.path().value()); |
107 ASSERT_TRUE(file_util::CreateDirectory( | 107 ASSERT_TRUE(file_util::CreateDirectory( |
108 temp_dir.path().AppendASCII("applications"))); | 108 temp_dir.path().AppendASCII("applications"))); |
109 ASSERT_TRUE(file_util::WriteFile( | 109 ASSERT_TRUE(file_util::WriteFile( |
110 temp_dir.path().AppendASCII("applications") | 110 temp_dir.path().AppendASCII("applications") |
111 .AppendASCII(kTemplateFilename), | 111 .AppendASCII(kTemplateFilename), |
112 kTestData2, strlen(kTestData2))); | 112 kTestData2, strlen(kTestData2))); |
113 std::string contents; | 113 std::string contents; |
114 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, | 114 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, |
115 &contents)); | 115 &contents)); |
116 EXPECT_EQ(kTestData2, contents); | 116 EXPECT_EQ(kTestData2, contents); |
117 } | 117 } |
118 | 118 |
119 { | 119 { |
120 ScopedTempDir temp_dir; | 120 base::ScopedTempDir temp_dir; |
121 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 121 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
122 | 122 |
123 MockEnvironment env; | 123 MockEnvironment env; |
124 env.Set("XDG_DATA_DIRS", temp_dir.path().value() + ":" + | 124 env.Set("XDG_DATA_DIRS", temp_dir.path().value() + ":" + |
125 temp_dir.path().AppendASCII("applications").value()); | 125 temp_dir.path().AppendASCII("applications").value()); |
126 ASSERT_TRUE(file_util::CreateDirectory( | 126 ASSERT_TRUE(file_util::CreateDirectory( |
127 temp_dir.path().AppendASCII("applications"))); | 127 temp_dir.path().AppendASCII("applications"))); |
128 ASSERT_TRUE(file_util::WriteFile( | 128 ASSERT_TRUE(file_util::WriteFile( |
129 temp_dir.path().AppendASCII(kTemplateFilename), | 129 temp_dir.path().AppendASCII(kTemplateFilename), |
130 kTestData1, strlen(kTestData1))); | 130 kTestData1, strlen(kTestData1))); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // Non-default profile path should get chrome::kBrowserAppID joined with | 386 // Non-default profile path should get chrome::kBrowserAppID joined with |
387 // profile info. | 387 // profile info. |
388 FilePath profile_path(FILE_PATH_LITERAL("root")); | 388 FilePath profile_path(FILE_PATH_LITERAL("root")); |
389 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); | 389 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); |
390 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); | 390 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); |
391 EXPECT_EQ(base_app_id + L".udd.UserDataTest", | 391 EXPECT_EQ(base_app_id + L".udd.UserDataTest", |
392 ShellIntegration::GetAppModelIdForProfile(base_app_id, | 392 ShellIntegration::GetAppModelIdForProfile(base_app_id, |
393 profile_path)); | 393 profile_path)); |
394 } | 394 } |
395 #endif | 395 #endif |
OLD | NEW |