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

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

Issue 9645003: Introduce abstractions to allow embedders to test RenderViewHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
11 #include "chrome/browser/ui/web_applications/web_app_ui.h" 11 #include "chrome/browser/ui/web_applications/web_app_ui.h"
12 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/test/test_browser_thread.h" 14 #include "content/test/test_browser_thread.h"
15 #include "content/test/test_renderer_host.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 class WebApplicationTest : public TabContentsWrapperTestHarness { 20 class WebApplicationTest : public TabContentsWrapperTestHarness {
20 public: 21 public:
21 WebApplicationTest() : ui_thread_(BrowserThread::UI, &message_loop_) { 22 WebApplicationTest() : ui_thread_(BrowserThread::UI, &message_loop_) {
22 } 23 }
23 24
24 private: 25 private:
25 content::TestBrowserThread ui_thread_; 26 content::TestBrowserThread ui_thread_;
26 }; 27 };
27 28
28 TEST_F(WebApplicationTest, GetShortcutInfoForTab) { 29 TEST_F(WebApplicationTest, GetShortcutInfoForTab) {
29 const string16 title = ASCIIToUTF16("TEST_TITLE"); 30 const string16 title = ASCIIToUTF16("TEST_TITLE");
30 const string16 description = ASCIIToUTF16("TEST_DESCRIPTION"); 31 const string16 description = ASCIIToUTF16("TEST_DESCRIPTION");
31 const GURL url("http://www.foo.com/bar"); 32 const GURL url("http://www.foo.com/bar");
32 WebApplicationInfo web_app_info; 33 WebApplicationInfo web_app_info;
33 web_app_info.title = title; 34 web_app_info.title = title;
34 web_app_info.description = description; 35 web_app_info.description = description;
35 web_app_info.app_url = url; 36 web_app_info.app_url = url;
36 37
37 rvh()->TestOnMessageReceived( 38 rvh_tester()->TestOnMessageReceived(
38 ExtensionHostMsg_DidGetApplicationInfo(0, 0, web_app_info)); 39 ExtensionHostMsg_DidGetApplicationInfo(0, 0, web_app_info));
39 ShellIntegration::ShortcutInfo info; 40 ShellIntegration::ShortcutInfo info;
40 web_app::GetShortcutInfoForTab(contents_wrapper(), &info); 41 web_app::GetShortcutInfoForTab(contents_wrapper(), &info);
41 42
42 EXPECT_EQ(title, info.title); 43 EXPECT_EQ(title, info.title);
43 EXPECT_EQ(description, info.description); 44 EXPECT_EQ(description, info.description);
44 EXPECT_EQ(url, info.url); 45 EXPECT_EQ(url, info.url);
45 } 46 }
46 47
47 TEST_F(WebApplicationTest, AppDirWithId) { 48 TEST_F(WebApplicationTest, AppDirWithId) {
48 FilePath profile_path(FILE_PATH_LITERAL("profile")); 49 FilePath profile_path(FILE_PATH_LITERAL("profile"));
49 FilePath result(web_app::GetWebAppDataDirectory(profile_path, "123", GURL())); 50 FilePath result(web_app::GetWebAppDataDirectory(profile_path, "123", GURL()));
50 FilePath expected = profile_path.AppendASCII("Web Applications") 51 FilePath expected = profile_path.AppendASCII("Web Applications")
51 .AppendASCII("_crx_123"); 52 .AppendASCII("_crx_123");
52 EXPECT_EQ(expected, result); 53 EXPECT_EQ(expected, result);
53 } 54 }
54 55
55 TEST_F(WebApplicationTest, AppDirWithUrl) { 56 TEST_F(WebApplicationTest, AppDirWithUrl) {
56 FilePath profile_path(FILE_PATH_LITERAL("profile")); 57 FilePath profile_path(FILE_PATH_LITERAL("profile"));
57 FilePath result(web_app::GetWebAppDataDirectory( 58 FilePath result(web_app::GetWebAppDataDirectory(
58 profile_path, "", GURL("http://example.com"))); 59 profile_path, "", GURL("http://example.com")));
59 FilePath expected = profile_path.AppendASCII("Web Applications") 60 FilePath expected = profile_path.AppendASCII("Web Applications")
60 .AppendASCII("example.com") 61 .AppendASCII("example.com")
61 .AppendASCII("http_80"); 62 .AppendASCII("http_80");
62 EXPECT_EQ(expected, result); 63 EXPECT_EQ(expected, result);
63 } 64 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink/visitedlink_unittest.cc ('k') | chrome/test/base/browser_with_test_window_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698