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

Side by Side Diff: chrome/browser/apps/drive/drive_app_converter_browsertest.cc

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/app_list/drive/drive_app_converter.h" 5 #include "chrome/browser/apps/drive/drive_app_converter.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/version.h" 12 #include "base/version.h"
13 #include "chrome/browser/extensions/extension_browsertest.h" 13 #include "chrome/browser/extensions/extension_browsertest.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_util.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/extensions/extension_constants.h" 17 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
18 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
21 #include "extensions/common/manifest_handlers/icons_handler.h" 22 #include "extensions/common/manifest_handlers/icons_handler.h"
22 #include "extensions/common/permissions/permission_set.h" 23 #include "extensions/common/permissions/permission_set.h"
23 #include "extensions/common/permissions/permissions_data.h" 24 #include "extensions/common/permissions/permissions_data.h"
24 #include "net/test/embedded_test_server/embedded_test_server.h" 25 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
28 using extensions::AppLaunchInfo;
29 using extensions::Extension;
30 using extensions::ExtensionRegistry;
31
27 namespace { 32 namespace {
28 33
29 const char kAppName[] = "Test drive app"; 34 const char kAppName[] = "Test drive app";
30 const char kAppUrl[] = "http://foobar.com/drive_app"; 35 const char kAppUrl[] = "http://foobar.com/drive_app";
31 36
32 } // namespace 37 } // namespace
33 38
34 class DriveAppConverterTest : public ExtensionBrowserTest { 39 class DriveAppConverterTest : public ExtensionBrowserTest {
35 public: 40 public:
36 DriveAppConverterTest() {} 41 DriveAppConverterTest() {}
37 virtual ~DriveAppConverterTest() {} 42 virtual ~DriveAppConverterTest() {}
38 43
39 // ExtensionBrowserTest: 44 // ExtensionBrowserTest:
40 virtual void SetUpOnMainThread() OVERRIDE { 45 virtual void SetUpOnMainThread() OVERRIDE {
41 ExtensionBrowserTest::SetUpOnMainThread(); 46 ExtensionBrowserTest::SetUpOnMainThread();
42 47
43 base::FilePath test_data_dir; 48 base::FilePath test_data_dir;
44 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 49 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 101
97 scoped_ptr<DriveAppConverter> converter_; 102 scoped_ptr<DriveAppConverter> converter_;
98 scoped_refptr<content::MessageLoopRunner> runner_; 103 scoped_refptr<content::MessageLoopRunner> runner_;
99 104
100 DISALLOW_COPY_AND_ASSIGN(DriveAppConverterTest); 105 DISALLOW_COPY_AND_ASSIGN(DriveAppConverterTest);
101 }; 106 };
102 107
103 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, GoodApp) { 108 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, GoodApp) {
104 InstallAndWaitFinish(GetTestDriveApp()); 109 InstallAndWaitFinish(GetTestDriveApp());
105 110
106 const extensions::Extension* app = converter()->app(); 111 const Extension* app = converter()->extension();
107 ASSERT_TRUE(app != NULL); 112 ASSERT_TRUE(app != NULL);
108 EXPECT_EQ(kAppName, app->name()); 113 EXPECT_EQ(kAppName, app->name());
109 EXPECT_TRUE(app->is_hosted_app()); 114 EXPECT_TRUE(app->is_hosted_app());
110 EXPECT_TRUE(app->from_bookmark()); 115 EXPECT_TRUE(app->from_bookmark());
111 EXPECT_EQ(GURL(kAppUrl), extensions::AppLaunchInfo::GetLaunchWebURL(app)); 116 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(app));
112 EXPECT_EQ(extensions::LAUNCH_CONTAINER_TAB, 117 EXPECT_EQ(extensions::LAUNCH_CONTAINER_TAB,
113 extensions::AppLaunchInfo::GetLaunchContainer(app)); 118 AppLaunchInfo::GetLaunchContainer(app));
114 EXPECT_EQ(0u, app->permissions_data()->active_permissions()->apis().size()); 119 EXPECT_EQ(0u, app->permissions_data()->active_permissions()->apis().size());
115 EXPECT_EQ(1u, extensions::IconsInfo::GetIcons(app).map().size()); 120 EXPECT_EQ(1u, extensions::IconsInfo::GetIcons(app).map().size());
116 121
117 const extensions::Extension* installed = 122 const Extension* installed = extensions::ExtensionSystem::Get(profile())
118 extensions::ExtensionSystem::Get(profile()) 123 ->extension_service()
119 ->extension_service() 124 ->GetInstalledExtension(app->id());
120 ->GetInstalledExtension(app->id());
121 EXPECT_EQ(app, installed); 125 EXPECT_EQ(app, installed);
126 EXPECT_FALSE(extensions::util::ShouldSyncApp(app, profile()));
122 } 127 }
123 128
124 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, BadApp) { 129 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, BadApp) {
125 drive::DriveAppInfo no_name = GetTestDriveApp(); 130 drive::DriveAppInfo no_name = GetTestDriveApp();
126 no_name.app_name.clear(); 131 no_name.app_name.clear();
127 InstallAndWaitFinish(no_name); 132 InstallAndWaitFinish(no_name);
128 EXPECT_TRUE(converter()->app() == NULL); 133 EXPECT_TRUE(converter()->extension() == NULL);
129 134
130 drive::DriveAppInfo no_url = GetTestDriveApp(); 135 drive::DriveAppInfo no_url = GetTestDriveApp();
131 no_url.create_url = GURL(); 136 no_url.create_url = GURL();
132 InstallAndWaitFinish(no_url); 137 InstallAndWaitFinish(no_url);
133 EXPECT_TRUE(converter()->app() == NULL); 138 EXPECT_TRUE(converter()->extension() == NULL);
134 } 139 }
135 140
136 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, InstallTwice) { 141 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, InstallTwice) {
137 InstallAndWaitFinish(GetTestDriveApp()); 142 InstallAndWaitFinish(GetTestDriveApp());
138 const extensions::Extension* first_install = converter()->app(); 143 const Extension* first_install = converter()->extension();
139 ASSERT_TRUE(first_install != NULL); 144 ASSERT_TRUE(first_install != NULL);
145 EXPECT_TRUE(converter()->is_new_install());
140 const std::string first_install_id = first_install->id(); 146 const std::string first_install_id = first_install->id();
141 const base::Version first_install_version(first_install->VersionString()); 147 const base::Version first_install_version(first_install->VersionString());
142 ASSERT_TRUE(first_install_version.IsValid()); 148 ASSERT_TRUE(first_install_version.IsValid());
143 149
144 InstallAndWaitFinish(GetTestDriveApp()); 150 InstallAndWaitFinish(GetTestDriveApp());
145 const extensions::Extension* second_install = converter()->app(); 151 const Extension* second_install = converter()->extension();
146 ASSERT_TRUE(second_install != NULL); 152 ASSERT_TRUE(second_install != NULL);
153 EXPECT_FALSE(converter()->is_new_install());
147 154
148 // Two different app instances. 155 // Two different app instances.
149 ASSERT_NE(first_install, second_install); 156 ASSERT_NE(first_install, second_install);
150 EXPECT_EQ(first_install_id, second_install->id()); 157 EXPECT_EQ(first_install_id, second_install->id());
151 EXPECT_GE(second_install->version()->CompareTo(first_install_version), 0); 158 EXPECT_GE(second_install->version()->CompareTo(first_install_version), 0);
152 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/drive/drive_app_converter.cc ('k') | chrome/browser/apps/drive/drive_app_mapping.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698