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

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

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. Created 3 years, 6 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 <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 "extensions/features/features.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 #if defined(TOOLKIT_VIEWS) 19 #if defined(TOOLKIT_VIEWS)
20 #include "chrome/browser/extensions/tab_helper.h" 20 #include "chrome/browser/extensions/tab_helper.h"
21 #include "chrome/browser/favicon/favicon_utils.h" 21 #include "chrome/browser/favicon/favicon_utils.h"
22 #endif 22 #endif
23 23
24 using content::RenderViewHostTester;
25
26 class WebApplicationTest : public ChromeRenderViewHostTestHarness { 24 class WebApplicationTest : public ChromeRenderViewHostTestHarness {
27 protected: 25 protected:
28 void SetUp() override { 26 void SetUp() override {
29 ChromeRenderViewHostTestHarness::SetUp(); 27 ChromeRenderViewHostTestHarness::SetUp();
30 #if defined(TOOLKIT_VIEWS) 28 #if defined(TOOLKIT_VIEWS)
31 extensions::TabHelper::CreateForWebContents(web_contents()); 29 extensions::TabHelper::CreateForWebContents(web_contents());
32 favicon::CreateContentFaviconDriverForWebContents(web_contents()); 30 favicon::CreateContentFaviconDriverForWebContents(web_contents());
33 #endif 31 #endif
34 } 32 }
35 }; 33 };
36 34
37 #if defined(TOOLKIT_VIEWS) 35 #if defined(TOOLKIT_VIEWS)
38 TEST_F(WebApplicationTest, GetShortcutInfoForTab) { 36 TEST_F(WebApplicationTest, GetShortcutInfoForTab) {
39 const base::string16 title = base::ASCIIToUTF16("TEST_TITLE"); 37 const base::string16 title = base::ASCIIToUTF16("TEST_TITLE");
40 const base::string16 description = base::ASCIIToUTF16("TEST_DESCRIPTION"); 38 const base::string16 description = base::ASCIIToUTF16("TEST_DESCRIPTION");
41 const GURL url("http://www.foo.com/bar"); 39 const GURL url("http://www.foo.com/bar");
42 WebApplicationInfo web_app_info; 40 WebApplicationInfo web_app_info;
43 web_app_info.title = title; 41 web_app_info.title = title;
44 web_app_info.description = description; 42 web_app_info.description = description;
45 web_app_info.app_url = url; 43 web_app_info.app_url = url;
46 44
47 content::RenderFrameHostTester::For(main_rfh()) 45 content::RenderFrameHostTester::For(main_rfh())
48 ->InitializeRenderFrameIfNeeded(); 46 ->InitializeRenderFrameIfNeeded();
49 content::RenderFrameHostTester::TestOnMessageReceived( 47 content::RenderFrameHostTester::TestOnMessageReceived(
50 rvh()->GetMainFrame(), 48 main_rfh(), ChromeFrameHostMsg_DidGetWebApplicationInfo(0, web_app_info));
51 ChromeFrameHostMsg_DidGetWebApplicationInfo(0, web_app_info));
52 std::unique_ptr<web_app::ShortcutInfo> info = 49 std::unique_ptr<web_app::ShortcutInfo> info =
53 web_app::GetShortcutInfoForTab(web_contents()); 50 web_app::GetShortcutInfoForTab(web_contents());
54 51
55 EXPECT_EQ(title, info->title); 52 EXPECT_EQ(title, info->title);
56 EXPECT_EQ(description, info->description); 53 EXPECT_EQ(description, info->description);
57 EXPECT_EQ(url, info->url); 54 EXPECT_EQ(url, info->url);
58 } 55 }
59 #endif 56 #endif
60 57
61 #if BUILDFLAG(ENABLE_EXTENSIONS) 58 #if BUILDFLAG(ENABLE_EXTENSIONS)
62 TEST_F(WebApplicationTest, AppDirWithId) { 59 TEST_F(WebApplicationTest, AppDirWithId) {
63 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); 60 base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
64 base::FilePath result( 61 base::FilePath result(
65 web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); 62 web_app::GetWebAppDataDirectory(profile_path, "123", GURL()));
66 base::FilePath expected = profile_path.AppendASCII("Web Applications") 63 base::FilePath expected = profile_path.AppendASCII("Web Applications")
67 .AppendASCII("_crx_123"); 64 .AppendASCII("_crx_123");
68 EXPECT_EQ(expected, result); 65 EXPECT_EQ(expected, result);
69 } 66 }
70 67
71 TEST_F(WebApplicationTest, AppDirWithUrl) { 68 TEST_F(WebApplicationTest, AppDirWithUrl) {
72 base::FilePath profile_path(FILE_PATH_LITERAL("profile")); 69 base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
73 base::FilePath result(web_app::GetWebAppDataDirectory( 70 base::FilePath result(web_app::GetWebAppDataDirectory(
74 profile_path, std::string(), GURL("http://example.com"))); 71 profile_path, std::string(), GURL("http://example.com")));
75 base::FilePath expected = profile_path.AppendASCII("Web Applications") 72 base::FilePath expected = profile_path.AppendASCII("Web Applications")
76 .AppendASCII("example.com").AppendASCII("http_80"); 73 .AppendASCII("example.com").AppendASCII("http_80");
77 EXPECT_EQ(expected, result); 74 EXPECT_EQ(expected, result);
78 } 75 }
79 #endif // ENABLE_EXTENSIONS 76 #endif // ENABLE_EXTENSIONS
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_render_frame_ext.cc ('k') | chrome/renderer/autofill/form_autocomplete_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698