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/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 const GURL url("http://www.foo.com/bar"); | 41 const GURL url("http://www.foo.com/bar"); |
42 WebApplicationInfo web_app_info; | 42 WebApplicationInfo web_app_info; |
43 web_app_info.title = title; | 43 web_app_info.title = title; |
44 web_app_info.description = description; | 44 web_app_info.description = description; |
45 web_app_info.app_url = url; | 45 web_app_info.app_url = url; |
46 | 46 |
47 content::RenderFrameHostTester::For(main_rfh()) | 47 content::RenderFrameHostTester::For(main_rfh()) |
48 ->InitializeRenderFrameIfNeeded(); | 48 ->InitializeRenderFrameIfNeeded(); |
49 RenderViewHostTester::TestOnMessageReceived( | 49 RenderViewHostTester::TestOnMessageReceived( |
50 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info)); | 50 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info)); |
51 std::unique_ptr<web_app::ShortcutInfo> info = | 51 scoped_refptr<web_app::ShortcutInfo> info = |
52 web_app::GetShortcutInfoForTab(web_contents()); | 52 web_app::GetShortcutInfoForTab(web_contents()); |
53 | 53 |
54 EXPECT_EQ(title, info->title); | 54 EXPECT_EQ(title, info->title); |
55 EXPECT_EQ(description, info->description); | 55 EXPECT_EQ(description, info->description); |
56 EXPECT_EQ(url, info->url); | 56 EXPECT_EQ(url, info->url); |
57 } | 57 } |
58 #endif | 58 #endif |
59 | 59 |
60 #if BUILDFLAG(ENABLE_EXTENSIONS) | 60 #if BUILDFLAG(ENABLE_EXTENSIONS) |
61 TEST_F(WebApplicationTest, AppDirWithId) { | 61 TEST_F(WebApplicationTest, AppDirWithId) { |
62 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); | 62 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); |
63 base::FilePath result( | 63 base::FilePath result( |
64 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); | 64 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); |
65 base::FilePath expected = profile_path.AppendASCII("Web Applications") | 65 base::FilePath expected = profile_path.AppendASCII("Web Applications") |
66 .AppendASCII("_crx_123"); | 66 .AppendASCII("_crx_123"); |
67 EXPECT_EQ(expected, result); | 67 EXPECT_EQ(expected, result); |
68 } | 68 } |
69 | 69 |
70 TEST_F(WebApplicationTest, AppDirWithUrl) { | 70 TEST_F(WebApplicationTest, AppDirWithUrl) { |
71 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); | 71 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); |
72 base::FilePath result(web_app::GetWebAppDataDirectory( | 72 base::FilePath result(web_app::GetWebAppDataDirectory( |
73 profile_path, std::string(), GURL("http://example.com"))); | 73 profile_path, std::string(), GURL("http://example.com"))); |
74 base::FilePath expected = profile_path.AppendASCII("Web Applications") | 74 base::FilePath expected = profile_path.AppendASCII("Web Applications") |
75 .AppendASCII("example.com").AppendASCII("http_80"); | 75 .AppendASCII("example.com").AppendASCII("http_80"); |
76 EXPECT_EQ(expected, result); | 76 EXPECT_EQ(expected, result); |
77 } | 77 } |
78 #endif // ENABLE_EXTENSIONS | 78 #endif // ENABLE_EXTENSIONS |
OLD | NEW |