Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / web_applications / web_app_unittest.cc
blob7a3961d6979e0e10953264bea985168023ca7080
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
3 // found in the LICENSE file.
5 #include "chrome/browser/web_applications/web_app.h"
7 #include "base/file_path.h"
8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/tab_helper.h"
11 #include "chrome/browser/favicon/favicon_tab_helper.h"
12 #include "chrome/browser/ui/web_applications/web_app_ui.h"
13 #include "chrome/common/extensions/extension_messages.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "content/public/test/test_browser_thread.h"
16 #include "content/public/test/test_renderer_host.h"
17 #include "testing/gtest/include/gtest/gtest.h"
19 using content::BrowserThread;
20 using content::RenderViewHostTester;
22 class WebApplicationTest : public ChromeRenderViewHostTestHarness {
23 public:
24 WebApplicationTest() : ui_thread_(BrowserThread::UI, &message_loop_) {
27 private:
28 virtual void SetUp() OVERRIDE {
29 ChromeRenderViewHostTestHarness::SetUp();
30 extensions::TabHelper::CreateForWebContents(web_contents());
31 FaviconTabHelper::CreateForWebContents(web_contents());
34 content::TestBrowserThread ui_thread_;
37 #if defined(OS_MACOSX)
38 #define MAYBE_GetShortcutInfoForTab DISABLED_GetShortcutInfoForTab
39 #else
40 #define MAYBE_GetShortcutInfoForTab GetShortcutInfoForTab
41 #endif
42 TEST_F(WebApplicationTest, MAYBE_GetShortcutInfoForTab) {
43 const string16 title = ASCIIToUTF16("TEST_TITLE");
44 const string16 description = ASCIIToUTF16("TEST_DESCRIPTION");
45 const GURL url("http://www.foo.com/bar");
46 WebApplicationInfo web_app_info;
47 web_app_info.title = title;
48 web_app_info.description = description;
49 web_app_info.app_url = url;
51 RenderViewHostTester::TestOnMessageReceived(
52 rvh(),
53 ExtensionHostMsg_DidGetApplicationInfo(0, 0, web_app_info));
54 ShellIntegration::ShortcutInfo info;
55 web_app::GetShortcutInfoForTab(web_contents(), &info);
57 EXPECT_EQ(title, info.title);
58 EXPECT_EQ(description, info.description);
59 EXPECT_EQ(url, info.url);
62 TEST_F(WebApplicationTest, AppDirWithId) {
63 FilePath profile_path(FILE_PATH_LITERAL("profile"));
64 FilePath result(web_app::GetWebAppDataDirectory(profile_path, "123", GURL()));
65 FilePath expected = profile_path.AppendASCII("Web Applications")
66 .AppendASCII("_crx_123");
67 EXPECT_EQ(expected, result);
70 TEST_F(WebApplicationTest, AppDirWithUrl) {
71 FilePath profile_path(FILE_PATH_LITERAL("profile"));
72 FilePath result(web_app::GetWebAppDataDirectory(
73 profile_path, "", GURL("http://example.com")));
74 FilePath expected = profile_path.AppendASCII("Web Applications")
75 .AppendASCII("example.com")
76 .AppendASCII("http_80");
77 EXPECT_EQ(expected, result);