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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/web_applications/web_app.h" | 12 #include "chrome/browser/web_applications/web_app.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "content/public/test/test_renderer_host.h" | 15 #include "content/public/test/test_renderer_host.h" |
| 16 #include "extensions/features/features.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 #if defined(TOOLKIT_VIEWS) | 19 #if defined(TOOLKIT_VIEWS) |
19 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
20 #include "chrome/browser/favicon/favicon_utils.h" | 21 #include "chrome/browser/favicon/favicon_utils.h" |
21 #endif | 22 #endif |
22 | 23 |
23 using content::RenderViewHostTester; | 24 using content::RenderViewHostTester; |
24 | 25 |
25 class WebApplicationTest : public ChromeRenderViewHostTestHarness { | 26 class WebApplicationTest : public ChromeRenderViewHostTestHarness { |
(...skipping 23 matching lines...) Expand all Loading... |
49 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info)); | 50 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info)); |
50 std::unique_ptr<web_app::ShortcutInfo> info = | 51 std::unique_ptr<web_app::ShortcutInfo> info = |
51 web_app::GetShortcutInfoForTab(web_contents()); | 52 web_app::GetShortcutInfoForTab(web_contents()); |
52 | 53 |
53 EXPECT_EQ(title, info->title); | 54 EXPECT_EQ(title, info->title); |
54 EXPECT_EQ(description, info->description); | 55 EXPECT_EQ(description, info->description); |
55 EXPECT_EQ(url, info->url); | 56 EXPECT_EQ(url, info->url); |
56 } | 57 } |
57 #endif | 58 #endif |
58 | 59 |
59 #if defined(ENABLE_EXTENSIONS) | 60 #if BUILDFLAG(ENABLE_EXTENSIONS) |
60 TEST_F(WebApplicationTest, AppDirWithId) { | 61 TEST_F(WebApplicationTest, AppDirWithId) { |
61 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); | 62 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); |
62 base::FilePath result( | 63 base::FilePath result( |
63 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); | 64 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); |
64 base::FilePath expected = profile_path.AppendASCII("Web Applications") | 65 base::FilePath expected = profile_path.AppendASCII("Web Applications") |
65 .AppendASCII("_crx_123"); | 66 .AppendASCII("_crx_123"); |
66 EXPECT_EQ(expected, result); | 67 EXPECT_EQ(expected, result); |
67 } | 68 } |
68 | 69 |
69 TEST_F(WebApplicationTest, AppDirWithUrl) { | 70 TEST_F(WebApplicationTest, AppDirWithUrl) { |
70 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); | 71 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); |
71 base::FilePath result(web_app::GetWebAppDataDirectory( | 72 base::FilePath result(web_app::GetWebAppDataDirectory( |
72 profile_path, std::string(), GURL("http://example.com"))); | 73 profile_path, std::string(), GURL("http://example.com"))); |
73 base::FilePath expected = profile_path.AppendASCII("Web Applications") | 74 base::FilePath expected = profile_path.AppendASCII("Web Applications") |
74 .AppendASCII("example.com").AppendASCII("http_80"); | 75 .AppendASCII("example.com").AppendASCII("http_80"); |
75 EXPECT_EQ(expected, result); | 76 EXPECT_EQ(expected, result); |
76 } | 77 } |
77 #endif // ENABLE_EXTENSIONS | 78 #endif // ENABLE_EXTENSIONS |
OLD | NEW |