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

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

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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) 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_webapps_registry.h" 5 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chromeos/drive/drive_test_util.h" 15 #include "chrome/browser/chromeos/drive/drive_test_util.h"
16 #include "chrome/browser/google_apis/drive_api_parser.h" 16 #include "chrome/browser/google_apis/drive_api_parser.h"
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 using base::Value; 22 using base::Value;
23 using base::DictionaryValue; 23 using base::DictionaryValue;
24 using base::ListValue; 24 using base::ListValue;
25 25
26 namespace gdata { 26 namespace drive {
27 27
28 class DriveWebAppsRegistryTest : public testing::Test { 28 class DriveWebAppsRegistryTest : public testing::Test {
29 protected: 29 protected:
30 DriveWebAppsRegistryTest() 30 DriveWebAppsRegistryTest()
31 : ui_thread_(content::BrowserThread::UI, &message_loop_) { 31 : ui_thread_(content::BrowserThread::UI, &message_loop_) {
32 } 32 }
33 33
34 bool VerifyApp(const ScopedVector<DriveWebAppInfo>& list, 34 bool VerifyApp(const ScopedVector<DriveWebAppInfo>& list,
35 const std::string& web_store_id, 35 const std::string& web_store_id,
36 const std::string& app_id, 36 const std::string& app_id,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 is_primary); 69 is_primary);
70 } 70 }
71 71
72 private: 72 private:
73 MessageLoopForUI message_loop_; 73 MessageLoopForUI message_loop_;
74 content::TestBrowserThread ui_thread_; 74 content::TestBrowserThread ui_thread_;
75 }; 75 };
76 76
77 TEST_F(DriveWebAppsRegistryTest, LoadAndFindWebApps) { 77 TEST_F(DriveWebAppsRegistryTest, LoadAndFindWebApps) {
78 scoped_ptr<Value> document = 78 scoped_ptr<Value> document =
79 test_util::LoadJSONFile("gdata/account_metadata.json"); 79 gdata::test_util::LoadJSONFile("gdata/account_metadata.json");
80 ASSERT_TRUE(document.get()); 80 ASSERT_TRUE(document.get());
81 ASSERT_TRUE(document->GetType() == Value::TYPE_DICTIONARY); 81 ASSERT_TRUE(document->GetType() == Value::TYPE_DICTIONARY);
82 DictionaryValue* entry_value; 82 DictionaryValue* entry_value;
83 ASSERT_TRUE(reinterpret_cast<DictionaryValue*>(document.get())->GetDictionary( 83 ASSERT_TRUE(reinterpret_cast<DictionaryValue*>(document.get())->GetDictionary(
84 std::string("entry"), &entry_value)); 84 std::string("entry"), &entry_value));
85 ASSERT_TRUE(entry_value); 85 ASSERT_TRUE(entry_value);
86 86
87 // Load feed. 87 // Load feed.
88 scoped_ptr<AccountMetadataFeed> feed( 88 scoped_ptr<gdata::AccountMetadataFeed> feed(
89 AccountMetadataFeed::CreateFrom(*document)); 89 gdata::AccountMetadataFeed::CreateFrom(*document));
90 ASSERT_TRUE(feed.get()); 90 ASSERT_TRUE(feed.get());
91 scoped_ptr<DriveWebAppsRegistry> web_apps(new DriveWebAppsRegistry); 91 scoped_ptr<DriveWebAppsRegistry> web_apps(new DriveWebAppsRegistry);
92 web_apps->UpdateFromFeed(*feed.get()); 92 web_apps->UpdateFromFeed(*feed.get());
93 93
94 // Find by extension 'ext_1'. 94 // Find by extension 'ext_1'.
95 ScopedVector<DriveWebAppInfo> ext_1_results; 95 ScopedVector<DriveWebAppInfo> ext_1_results;
96 FilePath ext1_file(FILE_PATH_LITERAL("gdata/SampleFile.ext_1")); 96 FilePath ext1_file(FILE_PATH_LITERAL("gdata/SampleFile.ext_1"));
97 web_apps->GetWebAppsForFile(ext1_file, std::string(), &ext_1_results); 97 web_apps->GetWebAppsForFile(ext1_file, std::string(), &ext_1_results);
98 ASSERT_EQ(1U, ext_1_results.size()); 98 ASSERT_EQ(1U, ext_1_results.size());
99 EXPECT_TRUE(VerifyApp1(ext_1_results, true)); 99 EXPECT_TRUE(VerifyApp1(ext_1_results, true));
(...skipping 17 matching lines...) Expand all
117 ScopedVector<DriveWebAppInfo> mime_ext_results; 117 ScopedVector<DriveWebAppInfo> mime_ext_results;
118 FilePath mime_file(FILE_PATH_LITERAL("gdata/MimeFile.ext_2")); 118 FilePath mime_file(FILE_PATH_LITERAL("gdata/MimeFile.ext_2"));
119 web_apps->GetWebAppsForFile(mime_file, "application/test_type_2", 119 web_apps->GetWebAppsForFile(mime_file, "application/test_type_2",
120 &mime_ext_results); 120 &mime_ext_results);
121 ASSERT_EQ(2U, mime_ext_results.size()); 121 ASSERT_EQ(2U, mime_ext_results.size());
122 EXPECT_TRUE(VerifyApp1(mime_ext_results, true)); 122 EXPECT_TRUE(VerifyApp1(mime_ext_results, true));
123 EXPECT_TRUE(VerifyApp2(mime_ext_results, true)); 123 EXPECT_TRUE(VerifyApp2(mime_ext_results, true));
124 } 124 }
125 125
126 TEST_F(DriveWebAppsRegistryTest, LoadAndFindDriveWebApps) { 126 TEST_F(DriveWebAppsRegistryTest, LoadAndFindDriveWebApps) {
127 scoped_ptr<Value> document = test_util::LoadJSONFile("drive/applist.json"); 127 scoped_ptr<Value> document =
128 gdata::test_util::LoadJSONFile("drive/applist.json");
128 ASSERT_TRUE(document.get()); 129 ASSERT_TRUE(document.get());
129 ASSERT_TRUE(document->GetType() == Value::TYPE_DICTIONARY); 130 ASSERT_TRUE(document->GetType() == Value::TYPE_DICTIONARY);
130 131
131 // Load feed. 132 // Load feed.
132 scoped_ptr<AppList> app_list(AppList::CreateFrom(*document)); 133 scoped_ptr<gdata::AppList> app_list(gdata::AppList::CreateFrom(*document));
133 ASSERT_TRUE(app_list.get()); 134 ASSERT_TRUE(app_list.get());
134 scoped_ptr<DriveWebAppsRegistry> web_apps(new DriveWebAppsRegistry); 135 scoped_ptr<DriveWebAppsRegistry> web_apps(new DriveWebAppsRegistry);
135 web_apps->UpdateFromApplicationList(*app_list.get()); 136 web_apps->UpdateFromApplicationList(*app_list.get());
136 137
137 // Find by primary extension 'exe'. 138 // Find by primary extension 'exe'.
138 ScopedVector<DriveWebAppInfo> ext_results; 139 ScopedVector<DriveWebAppInfo> ext_results;
139 FilePath ext_file(FILE_PATH_LITERAL("drive/file.exe")); 140 FilePath ext_file(FILE_PATH_LITERAL("drive/file.exe"));
140 web_apps->GetWebAppsForFile(ext_file, std::string(), &ext_results); 141 web_apps->GetWebAppsForFile(ext_file, std::string(), &ext_results);
141 ASSERT_EQ(1U, ext_results.size()); 142 ASSERT_EQ(1U, ext_results.size());
142 VerifyApp(ext_results, "abcdefghabcdefghabcdefghabcdefgh", "123456788192", 143 VerifyApp(ext_results, "abcdefghabcdefghabcdefghabcdefgh", "123456788192",
143 "Drive app 1", "", true); 144 "Drive app 1", "", true);
144 145
145 // Find by primary MIME type. 146 // Find by primary MIME type.
146 ScopedVector<DriveWebAppInfo> primary_app; 147 ScopedVector<DriveWebAppInfo> primary_app;
147 web_apps->GetWebAppsForFile(FilePath(), 148 web_apps->GetWebAppsForFile(FilePath(),
148 "application/vnd.google-apps.drive-sdk.123456788192", &primary_app); 149 "application/vnd.google-apps.drive-sdk.123456788192", &primary_app);
149 ASSERT_EQ(1U, primary_app.size()); 150 ASSERT_EQ(1U, primary_app.size());
150 VerifyApp(primary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192", 151 VerifyApp(primary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192",
151 "Drive app 1", "", true); 152 "Drive app 1", "", true);
152 153
153 // Find by secondary MIME type. 154 // Find by secondary MIME type.
154 ScopedVector<DriveWebAppInfo> secondary_app; 155 ScopedVector<DriveWebAppInfo> secondary_app;
155 web_apps->GetWebAppsForFile(FilePath(), "text/html", &secondary_app); 156 web_apps->GetWebAppsForFile(FilePath(), "text/html", &secondary_app);
156 ASSERT_EQ(1U, secondary_app.size()); 157 ASSERT_EQ(1U, secondary_app.size());
157 VerifyApp(secondary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192", 158 VerifyApp(secondary_app, "abcdefghabcdefghabcdefghabcdefgh", "123456788192",
158 "Drive app 1", "", false); 159 "Drive app 1", "", false);
159 } 160 }
160 161
161 } // namespace gdata 162 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_webapps_registry.cc ('k') | chrome/browser/chromeos/drive/file_system/move_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698