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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_tasks_unittest.cc

Issue 106433007: Update some uses of Value in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_manager/file_tasks.h" 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 28 matching lines...) Expand all
39 39
40 pref_service->registry()->RegisterDictionaryPref( 40 pref_service->registry()->RegisterDictionaryPref(
41 prefs::kDefaultTasksByMimeType); 41 prefs::kDefaultTasksByMimeType);
42 pref_service->registry()->RegisterDictionaryPref( 42 pref_service->registry()->RegisterDictionaryPref(
43 prefs::kDefaultTasksBySuffix); 43 prefs::kDefaultTasksBySuffix);
44 } 44 }
45 45
46 // Updates the default task preferences per the given dictionary values. Used 46 // Updates the default task preferences per the given dictionary values. Used
47 // for testing ChooseAndSetDefaultTask. 47 // for testing ChooseAndSetDefaultTask.
48 void UpdateDefaultTaskPreferences(TestingPrefServiceSimple* pref_service, 48 void UpdateDefaultTaskPreferences(TestingPrefServiceSimple* pref_service,
49 const DictionaryValue& mime_types, 49 const base::DictionaryValue& mime_types,
50 const DictionaryValue& suffixes) { 50 const base::DictionaryValue& suffixes) {
51 DCHECK(pref_service); 51 DCHECK(pref_service);
52 52
53 pref_service->Set(prefs::kDefaultTasksByMimeType, mime_types); 53 pref_service->Set(prefs::kDefaultTasksByMimeType, mime_types);
54 pref_service->Set(prefs::kDefaultTasksBySuffix, suffixes); 54 pref_service->Set(prefs::kDefaultTasksBySuffix, suffixes);
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 TEST(FileManagerFileTasksTest, 59 TEST(FileManagerFileTasksTest,
60 FullTaskDescriptor_NonDriveAppWithIconAndDefault) { 60 FullTaskDescriptor_NonDriveAppWithIconAndDefault) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 base::FilePath::FromUTF8Unsafe("foo.txt"), 282 base::FilePath::FromUTF8Unsafe("foo.txt"),
283 "text/plain")); 283 "text/plain"));
284 284
285 // None of them should be chosen as default, as nothing is set in the 285 // None of them should be chosen as default, as nothing is set in the
286 // preferences. 286 // preferences.
287 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); 287 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks);
288 EXPECT_FALSE(tasks[0].is_default()); 288 EXPECT_FALSE(tasks[0].is_default());
289 EXPECT_FALSE(tasks[1].is_default()); 289 EXPECT_FALSE(tasks[1].is_default());
290 290
291 // Set Text.app as default for "text/plain" in the preferences. 291 // Set Text.app as default for "text/plain" in the preferences.
292 DictionaryValue empty; 292 base::DictionaryValue empty;
293 DictionaryValue mime_types; 293 base::DictionaryValue mime_types;
294 mime_types.SetStringWithoutPathExpansion( 294 mime_types.SetStringWithoutPathExpansion(
295 "text/plain", 295 "text/plain",
296 TaskDescriptorToId(text_app_task)); 296 TaskDescriptorToId(text_app_task));
297 UpdateDefaultTaskPreferences(&pref_service, mime_types, empty); 297 UpdateDefaultTaskPreferences(&pref_service, mime_types, empty);
298 298
299 // Text.app should be chosen as default. 299 // Text.app should be chosen as default.
300 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); 300 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks);
301 EXPECT_TRUE(tasks[0].is_default()); 301 EXPECT_TRUE(tasks[0].is_default());
302 EXPECT_FALSE(tasks[1].is_default()); 302 EXPECT_FALSE(tasks[1].is_default());
303 303
304 // Change it back to non-default for testing further. 304 // Change it back to non-default for testing further.
305 tasks[0].set_is_default(false); 305 tasks[0].set_is_default(false);
306 306
307 // Clear the preferences and make sure none of them are default. 307 // Clear the preferences and make sure none of them are default.
308 UpdateDefaultTaskPreferences(&pref_service, empty, empty); 308 UpdateDefaultTaskPreferences(&pref_service, empty, empty);
309 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); 309 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks);
310 EXPECT_FALSE(tasks[0].is_default()); 310 EXPECT_FALSE(tasks[0].is_default());
311 EXPECT_FALSE(tasks[1].is_default()); 311 EXPECT_FALSE(tasks[1].is_default());
312 312
313 // Set Nice.app as default for ".txt" in the preferences. 313 // Set Nice.app as default for ".txt" in the preferences.
314 DictionaryValue suffixes; 314 base::DictionaryValue suffixes;
315 suffixes.SetStringWithoutPathExpansion( 315 suffixes.SetStringWithoutPathExpansion(
316 ".txt", 316 ".txt",
317 TaskDescriptorToId(nice_app_task)); 317 TaskDescriptorToId(nice_app_task));
318 UpdateDefaultTaskPreferences(&pref_service, empty, suffixes); 318 UpdateDefaultTaskPreferences(&pref_service, empty, suffixes);
319 319
320 // Now Nice.app should be chosen as default. 320 // Now Nice.app should be chosen as default.
321 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); 321 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks);
322 EXPECT_FALSE(tasks[0].is_default()); 322 EXPECT_FALSE(tasks[0].is_default());
323 EXPECT_TRUE(tasks[1].is_default()); 323 EXPECT_TRUE(tasks[1].is_default());
324 } 324 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 &drive_app_registry, 727 &drive_app_registry,
728 path_mime_set, 728 path_mime_set,
729 file_urls, 729 file_urls,
730 &tasks); 730 &tasks);
731 ASSERT_EQ(1U, tasks.size()); 731 ASSERT_EQ(1U, tasks.size());
732 EXPECT_EQ(kFileManagerAppId, tasks[0].task_descriptor().app_id); 732 EXPECT_EQ(kFileManagerAppId, tasks[0].task_descriptor().app_id);
733 } 733 }
734 734
735 } // namespace file_tasks 735 } // namespace file_tasks
736 } // namespace file_manager. 736 } // namespace file_manager.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698