Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/web_applications/web_app_unittest.cc

Issue 1038573002: Fixed thread-unsafe use of gfx::Image in app shortcut creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/web_applications/web_app.h" 11 #include "chrome/browser/web_applications/web_app.h"
11 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "content/public/test/test_renderer_host.h" 14 #include "content/public/test/test_renderer_host.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #if defined(TOOLKIT_VIEWS) 17 #if defined(TOOLKIT_VIEWS)
17 #include "chrome/browser/extensions/tab_helper.h" 18 #include "chrome/browser/extensions/tab_helper.h"
(...skipping 18 matching lines...) Expand all
36 const base::string16 title = base::ASCIIToUTF16("TEST_TITLE"); 37 const base::string16 title = base::ASCIIToUTF16("TEST_TITLE");
37 const base::string16 description = base::ASCIIToUTF16("TEST_DESCRIPTION"); 38 const base::string16 description = base::ASCIIToUTF16("TEST_DESCRIPTION");
38 const GURL url("http://www.foo.com/bar"); 39 const GURL url("http://www.foo.com/bar");
39 WebApplicationInfo web_app_info; 40 WebApplicationInfo web_app_info;
40 web_app_info.title = title; 41 web_app_info.title = title;
41 web_app_info.description = description; 42 web_app_info.description = description;
42 web_app_info.app_url = url; 43 web_app_info.app_url = url;
43 44
44 RenderViewHostTester::TestOnMessageReceived( 45 RenderViewHostTester::TestOnMessageReceived(
45 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info)); 46 rvh(), ChromeViewHostMsg_DidGetWebApplicationInfo(0, web_app_info));
46 web_app::ShortcutInfo info; 47 scoped_ptr<web_app::ShortcutInfo> info =
47 web_app::GetShortcutInfoForTab(web_contents(), &info); 48 web_app::GetShortcutInfoForTab(web_contents());
48 49
49 EXPECT_EQ(title, info.title); 50 EXPECT_EQ(title, info->title);
50 EXPECT_EQ(description, info.description); 51 EXPECT_EQ(description, info->description);
51 EXPECT_EQ(url, info.url); 52 EXPECT_EQ(url, info->url);
52 } 53 }
53 #endif 54 #endif
54 55
55 #if defined(ENABLE_EXTENSIONS) 56 #if defined(ENABLE_EXTENSIONS)
56 TEST_F(WebApplicationTest, AppDirWithId) { 57 TEST_F(WebApplicationTest, AppDirWithId) {
57 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); 58 base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
58 base::FilePath result( 59 base::FilePath result(
59 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); 60 web_app::GetWebAppDataDirectory(profile_path, "123", GURL()));
60 base::FilePath expected = profile_path.AppendASCII("Web Applications") 61 base::FilePath expected = profile_path.AppendASCII("Web Applications")
61 .AppendASCII("_crx_123"); 62 .AppendASCII("_crx_123");
62 EXPECT_EQ(expected, result); 63 EXPECT_EQ(expected, result);
63 } 64 }
64 65
65 TEST_F(WebApplicationTest, AppDirWithUrl) { 66 TEST_F(WebApplicationTest, AppDirWithUrl) {
66 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); 67 base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
67 base::FilePath result(web_app::GetWebAppDataDirectory( 68 base::FilePath result(web_app::GetWebAppDataDirectory(
68 profile_path, std::string(), GURL("http://example.com"))); 69 profile_path, std::string(), GURL("http://example.com")));
69 base::FilePath expected = profile_path.AppendASCII("Web Applications") 70 base::FilePath expected = profile_path.AppendASCII("Web Applications")
70 .AppendASCII("example.com").AppendASCII("http_80"); 71 .AppendASCII("example.com").AppendASCII("http_80");
71 EXPECT_EQ(expected, result); 72 EXPECT_EQ(expected, result);
72 } 73 }
73 #endif // ENABLE_EXTENSIONS 74 #endif // ENABLE_EXTENSIONS
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_mac_unittest.mm ('k') | chrome/browser/web_applications/web_app_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698