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

Side by Side Diff: chrome/browser/chromeos/drive/drive_app_registry_unittest.cc

Issue 23503008: file_manager: Add DriveAppRegistry::UpdateFromAppList() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « chrome/browser/chromeos/drive/drive_app_registry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/drive/drive_app_registry.h" 5 #include "chrome/browser/chromeos/drive/drive_app_registry.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/prefs/testing_pref_service.h" 8 #include "base/prefs/testing_pref_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/drive/job_scheduler.h" 10 #include "chrome/browser/chromeos/drive/job_scheduler.h"
11 #include "chrome/browser/chromeos/drive/test_util.h" 11 #include "chrome/browser/chromeos/drive/test_util.h"
12 #include "chrome/browser/drive/fake_drive_service.h" 12 #include "chrome/browser/drive/fake_drive_service.h"
13 #include "chrome/browser/google_apis/drive_api_parser.h"
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 14 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
15 #include "chrome/browser/google_apis/test_util.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 16 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 namespace drive { 19 namespace drive {
18 20
19 class DriveAppRegistryTest : public testing::Test { 21 class DriveAppRegistryTest : public testing::Test {
20 protected: 22 protected:
21 virtual void SetUp() OVERRIDE { 23 virtual void SetUp() OVERRIDE {
22 pref_service_.reset(new TestingPrefServiceSimple); 24 pref_service_.reset(new TestingPrefServiceSimple);
23 test_util::RegisterDrivePrefs(pref_service_->registry()); 25 test_util::RegisterDrivePrefs(pref_service_->registry());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 87
86 // Find by secondary MIME type. 88 // Find by secondary MIME type.
87 ScopedVector<DriveAppInfo> secondary_app; 89 ScopedVector<DriveAppInfo> secondary_app;
88 web_apps_registry_->GetAppsForFile( 90 web_apps_registry_->GetAppsForFile(
89 base::FilePath(), "text/html", &secondary_app); 91 base::FilePath(), "text/html", &secondary_app);
90 ASSERT_EQ(1U, secondary_app.size()); 92 ASSERT_EQ(1U, secondary_app.size());
91 VerifyApp(secondary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192", 93 VerifyApp(secondary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192",
92 "Drive app 1", "", false); 94 "Drive app 1", "", false);
93 } 95 }
94 96
97 TEST_F(DriveAppRegistryTest, UpdateFromAppList) {
98 scoped_ptr<base::Value> app_info_value =
99 google_apis::test_util::LoadJSONFile("drive/applist.json");
100 scoped_ptr<google_apis::AppList> app_list(
101 google_apis::AppList::CreateFrom(*app_info_value));
102
103 web_apps_registry_->UpdateFromAppList(*app_list);
104
105 // Confirm that something was loaded from applist.json.
106 ScopedVector<DriveAppInfo> ext_results;
107 base::FilePath ext_file(FILE_PATH_LITERAL("drive/file.exe"));
108 web_apps_registry_->GetAppsForFile(ext_file, std::string(), &ext_results);
109 ASSERT_EQ(1U, ext_results.size());
110 }
111
95 TEST_F(DriveAppRegistryTest, MultipleUpdate) { 112 TEST_F(DriveAppRegistryTest, MultipleUpdate) {
96 // Call Update(). 113 // Call Update().
97 web_apps_registry_->Update(); 114 web_apps_registry_->Update();
98 115
99 // Call Update() again. 116 // Call Update() again.
100 // This call should be ignored because there is already an ongoing update. 117 // This call should be ignored because there is already an ongoing update.
101 web_apps_registry_->Update(); 118 web_apps_registry_->Update();
102 119
103 // The app list should be loaded only once. 120 // The app list should be loaded only once.
104 base::RunLoop().RunUntilIdle(); 121 base::RunLoop().RunUntilIdle();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // should be returned. 154 // should be returned.
138 EXPECT_EQ(kSmallerIconUrl, 155 EXPECT_EQ(kSmallerIconUrl,
139 util::FindPreferredIcon(icons, kMediumSize - 3).spec()); 156 util::FindPreferredIcon(icons, kMediumSize - 3).spec());
140 // The requested size is larger than the largest icon. The largest icon 157 // The requested size is larger than the largest icon. The largest icon
141 // should be returned. 158 // should be returned.
142 EXPECT_EQ(kBiggerIconUrl, 159 EXPECT_EQ(kBiggerIconUrl,
143 util::FindPreferredIcon(icons, kMediumSize + 3).spec()); 160 util::FindPreferredIcon(icons, kMediumSize + 3).spec());
144 } 161 }
145 162
146 } // namespace drive 163 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_app_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698