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

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: for comemnts in #5 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/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/extensions/extension_constants.h" 16 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
18 #include "chrome/common/extensions/sync_helper.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 "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
27 using extensions::AppLaunchInfo;
28 using extensions::Extension;
29 using extensions::ExtensionRegistry;
30
26 namespace { 31 namespace {
27 32
28 const char kAppName[] = "Test drive app"; 33 const char kAppName[] = "Test drive app";
29 const char kAppUrl[] = "http://foobar.com/drive_app"; 34 const char kAppUrl[] = "http://foobar.com/drive_app";
30 35
31 } // namespace 36 } // namespace
32 37
33 class DriveAppConverterTest : public ExtensionBrowserTest { 38 class DriveAppConverterTest : public ExtensionBrowserTest {
34 public: 39 public:
35 DriveAppConverterTest() {} 40 DriveAppConverterTest() {}
36 virtual ~DriveAppConverterTest() {} 41 virtual ~DriveAppConverterTest() {}
37 42
38 // ExtensionBrowserTest: 43 // ExtensionBrowserTest:
39 virtual void SetUpOnMainThread() OVERRIDE { 44 virtual void SetUpOnMainThread() OVERRIDE {
40 ExtensionBrowserTest::SetUpOnMainThread(); 45 ExtensionBrowserTest::SetUpOnMainThread();
41 46
42 base::FilePath test_data_dir; 47 base::FilePath test_data_dir;
43 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 48 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 100
96 scoped_ptr<DriveAppConverter> converter_; 101 scoped_ptr<DriveAppConverter> converter_;
97 scoped_refptr<content::MessageLoopRunner> runner_; 102 scoped_refptr<content::MessageLoopRunner> runner_;
98 103
99 DISALLOW_COPY_AND_ASSIGN(DriveAppConverterTest); 104 DISALLOW_COPY_AND_ASSIGN(DriveAppConverterTest);
100 }; 105 };
101 106
102 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, GoodApp) { 107 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, GoodApp) {
103 InstallAndWaitFinish(GetTestDriveApp()); 108 InstallAndWaitFinish(GetTestDriveApp());
104 109
105 const extensions::Extension* app = converter()->app(); 110 const Extension* app = converter()->app();
106 ASSERT_TRUE(app != NULL); 111 ASSERT_TRUE(app != NULL);
107 EXPECT_EQ(kAppName, app->name()); 112 EXPECT_EQ(kAppName, app->name());
108 EXPECT_TRUE(app->is_hosted_app()); 113 EXPECT_TRUE(app->is_hosted_app());
109 EXPECT_TRUE(app->from_bookmark()); 114 EXPECT_TRUE(app->from_bookmark());
110 EXPECT_EQ(GURL(kAppUrl), extensions::AppLaunchInfo::GetLaunchWebURL(app)); 115 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(app));
111 EXPECT_EQ(extensions::LAUNCH_CONTAINER_TAB, 116 EXPECT_EQ(extensions::LAUNCH_CONTAINER_TAB,
112 extensions::AppLaunchInfo::GetLaunchContainer(app)); 117 AppLaunchInfo::GetLaunchContainer(app));
113 EXPECT_EQ(0u, app->GetActivePermissions()->apis().size()); 118 EXPECT_EQ(0u, app->GetActivePermissions()->apis().size());
114 EXPECT_EQ(1u, extensions::IconsInfo::GetIcons(app).map().size()); 119 EXPECT_EQ(1u, extensions::IconsInfo::GetIcons(app).map().size());
115 120
116 const extensions::Extension* installed = 121 const Extension* installed = extensions::ExtensionSystem::Get(profile())
117 extensions::ExtensionSystem::Get(profile()) 122 ->extension_service()
118 ->extension_service() 123 ->GetInstalledExtension(app->id());
119 ->GetInstalledExtension(app->id());
120 EXPECT_EQ(app, installed); 124 EXPECT_EQ(app, installed);
125 EXPECT_FALSE(extensions::sync_helper::IsSyncable(app));
121 } 126 }
122 127
123 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, BadApp) { 128 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, BadApp) {
124 drive::DriveAppInfo no_name = GetTestDriveApp(); 129 drive::DriveAppInfo no_name = GetTestDriveApp();
125 no_name.app_name.clear(); 130 no_name.app_name.clear();
126 InstallAndWaitFinish(no_name); 131 InstallAndWaitFinish(no_name);
127 EXPECT_TRUE(converter()->app() == NULL); 132 EXPECT_TRUE(converter()->app() == NULL);
128 133
129 drive::DriveAppInfo no_url = GetTestDriveApp(); 134 drive::DriveAppInfo no_url = GetTestDriveApp();
130 no_url.create_url = GURL(); 135 no_url.create_url = GURL();
131 InstallAndWaitFinish(no_url); 136 InstallAndWaitFinish(no_url);
132 EXPECT_TRUE(converter()->app() == NULL); 137 EXPECT_TRUE(converter()->app() == NULL);
133 } 138 }
134 139
135 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, InstallTwice) { 140 IN_PROC_BROWSER_TEST_F(DriveAppConverterTest, InstallTwice) {
136 InstallAndWaitFinish(GetTestDriveApp()); 141 InstallAndWaitFinish(GetTestDriveApp());
137 const extensions::Extension* first_install = converter()->app(); 142 const Extension* first_install = converter()->app();
138 ASSERT_TRUE(first_install != NULL); 143 ASSERT_TRUE(first_install != NULL);
139 const std::string first_install_id = first_install->id(); 144 const std::string first_install_id = first_install->id();
140 const base::Version first_install_version(first_install->VersionString()); 145 const base::Version first_install_version(first_install->VersionString());
141 ASSERT_TRUE(first_install_version.IsValid()); 146 ASSERT_TRUE(first_install_version.IsValid());
142 147
143 InstallAndWaitFinish(GetTestDriveApp()); 148 InstallAndWaitFinish(GetTestDriveApp());
144 const extensions::Extension* second_install = converter()->app(); 149 const Extension* second_install = converter()->app();
145 ASSERT_TRUE(second_install != NULL); 150 ASSERT_TRUE(second_install != NULL);
146 151
147 // Two different app instances. 152 // Two different app instances.
148 ASSERT_NE(first_install, second_install); 153 ASSERT_NE(first_install, second_install);
149 EXPECT_EQ(first_install_id, second_install->id()); 154 EXPECT_EQ(first_install_id, second_install->id());
150 EXPECT_GE(second_install->version()->CompareTo(first_install_version), 0); 155 EXPECT_GE(second_install->version()->CompareTo(first_install_version), 0);
151 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698