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 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/xattr.h> | 10 #include <sys/xattr.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
17 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
18 #include "base/mac/scoped_nsobject.h" | 18 #include "base/mac/scoped_nsobject.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/strings/sys_string_conversions.h" | 21 #include "base/strings/sys_string_conversions.h" |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #import "chrome/common/mac/app_mode_common.h" | 25 #import "chrome/common/mac/app_mode_common.h" |
26 #include "chrome/grit/theme_resources.h" | 26 #include "chrome/grit/theme_resources.h" |
27 #include "components/version_info/version_info.h" | 27 #include "components/version_info/version_info.h" |
| 28 #include "content/public/test/test_browser_thread_bundle.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 #import "testing/gtest_mac.h" | 31 #import "testing/gtest_mac.h" |
31 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
32 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
33 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
34 | 35 |
35 using ::testing::_; | 36 using ::testing::_; |
36 using ::testing::Return; | 37 using ::testing::Return; |
37 using ::testing::NiceMock; | 38 using ::testing::NiceMock; |
(...skipping 10 matching lines...) Expand all Loading... |
48 | 49 |
49 MOCK_CONST_METHOD0(GetApplicationsDirname, base::FilePath()); | 50 MOCK_CONST_METHOD0(GetApplicationsDirname, base::FilePath()); |
50 MOCK_CONST_METHOD1(GetAppBundleById, | 51 MOCK_CONST_METHOD1(GetAppBundleById, |
51 base::FilePath(const std::string& bundle_id)); | 52 base::FilePath(const std::string& bundle_id)); |
52 MOCK_CONST_METHOD0(RevealAppShimInFinder, void()); | 53 MOCK_CONST_METHOD0(RevealAppShimInFinder, void()); |
53 | 54 |
54 private: | 55 private: |
55 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreatorMock); | 56 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreatorMock); |
56 }; | 57 }; |
57 | 58 |
58 std::unique_ptr<web_app::ShortcutInfo> GetShortcutInfo() { | 59 scoped_refptr<web_app::ShortcutInfo> GetShortcutInfo() { |
59 std::unique_ptr<web_app::ShortcutInfo> info(new web_app::ShortcutInfo); | 60 scoped_refptr<web_app::ShortcutInfo> info(new web_app::ShortcutInfo); |
60 info->extension_id = "extensionid"; | 61 info->extension_id = "extensionid"; |
61 info->extension_path = base::FilePath("/fake/extension/path"); | 62 info->extension_path = base::FilePath("/fake/extension/path"); |
62 info->title = base::ASCIIToUTF16("Shortcut Title"); | 63 info->title = base::ASCIIToUTF16("Shortcut Title"); |
63 info->url = GURL("http://example.com/"); | 64 info->url = GURL("http://example.com/"); |
64 info->profile_path = base::FilePath("user_data_dir").Append("Profile 1"); | 65 info->profile_path = base::FilePath("user_data_dir").Append("Profile 1"); |
65 info->profile_name = "profile name"; | 66 info->profile_name = "profile name"; |
66 info->version_for_display = "stable 1.0"; | 67 info->version_for_display = "stable 1.0"; |
67 info->from_bookmark = false; | 68 info->from_bookmark = false; |
68 return info; | 69 return info; |
69 } | 70 } |
(...skipping 10 matching lines...) Expand all Loading... |
80 app_data_dir_ = temp_app_data_dir_.GetPath(); | 81 app_data_dir_ = temp_app_data_dir_.GetPath(); |
81 destination_dir_ = temp_destination_dir_.GetPath(); | 82 destination_dir_ = temp_destination_dir_.GetPath(); |
82 | 83 |
83 info_ = GetShortcutInfo(); | 84 info_ = GetShortcutInfo(); |
84 shim_base_name_ = base::FilePath(info_->profile_path.BaseName().value() + | 85 shim_base_name_ = base::FilePath(info_->profile_path.BaseName().value() + |
85 " " + info_->extension_id + ".app"); | 86 " " + info_->extension_id + ".app"); |
86 internal_shim_path_ = app_data_dir_.Append(shim_base_name_); | 87 internal_shim_path_ = app_data_dir_.Append(shim_base_name_); |
87 shim_path_ = destination_dir_.Append(shim_base_name_); | 88 shim_path_ = destination_dir_.Append(shim_base_name_); |
88 } | 89 } |
89 | 90 |
| 91 content::TestBrowserThreadBundle thread_bundle_; |
| 92 |
90 base::ScopedTempDir temp_app_data_dir_; | 93 base::ScopedTempDir temp_app_data_dir_; |
91 base::ScopedTempDir temp_destination_dir_; | 94 base::ScopedTempDir temp_destination_dir_; |
92 base::FilePath app_data_dir_; | 95 base::FilePath app_data_dir_; |
93 base::FilePath destination_dir_; | 96 base::FilePath destination_dir_; |
94 | 97 |
95 std::unique_ptr<web_app::ShortcutInfo> info_; | 98 scoped_refptr<web_app::ShortcutInfo> info_; |
96 base::FilePath shim_base_name_; | 99 base::FilePath shim_base_name_; |
97 base::FilePath internal_shim_path_; | 100 base::FilePath internal_shim_path_; |
98 base::FilePath shim_path_; | 101 base::FilePath shim_path_; |
99 | 102 |
100 private: | 103 private: |
101 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreatorTest); | 104 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreatorTest); |
102 }; | 105 }; |
103 | 106 |
104 | 107 |
105 } // namespace | 108 } // namespace |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 .Times(0); | 332 .Times(0); |
330 EXPECT_TRUE(shortcut_creator.CreateShortcuts( | 333 EXPECT_TRUE(shortcut_creator.CreateShortcuts( |
331 SHORTCUT_CREATION_AUTOMATED, web_app::ShortcutLocations())); | 334 SHORTCUT_CREATION_AUTOMATED, web_app::ShortcutLocations())); |
332 | 335 |
333 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()); | 336 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()); |
334 EXPECT_TRUE(shortcut_creator.CreateShortcuts( | 337 EXPECT_TRUE(shortcut_creator.CreateShortcuts( |
335 SHORTCUT_CREATION_BY_USER, web_app::ShortcutLocations())); | 338 SHORTCUT_CREATION_BY_USER, web_app::ShortcutLocations())); |
336 } | 339 } |
337 | 340 |
338 } // namespace web_app | 341 } // namespace web_app |
OLD | NEW |