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

Side by Side Diff: chrome/browser/media_galleries/media_galleries_permission_controller_unittest.cc

Issue 318733003: Use the media galleries controller interface for the scan result dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more const 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 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/extensions/test_extension_system.h" 12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/media_galleries/media_galleries_dialog_controller_test_ util.h"
13 #include "chrome/browser/media_galleries/media_galleries_permission_controller.h " 14 #include "chrome/browser/media_galleries/media_galleries_permission_controller.h "
14 #include "chrome/browser/media_galleries/media_galleries_preferences.h" 15 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
15 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 16 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "components/storage_monitor/storage_info.h" 18 #include "components/storage_monitor/storage_info.h"
18 #include "components/storage_monitor/test_storage_monitor.h" 19 #include "components/storage_monitor/test_storage_monitor.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "extensions/common/permissions/media_galleries_permission.h" 21 #include "extensions/common/permissions/media_galleries_permission.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/login/users/user_manager.h" 25 #include "chrome/browser/chromeos/login/users/user_manager.h"
25 #include "chrome/browser/chromeos/settings/cros_settings.h" 26 #include "chrome/browser/chromeos/settings/cros_settings.h"
26 #include "chrome/browser/chromeos/settings/device_settings_service.h" 27 #include "chrome/browser/chromeos/settings/device_settings_service.h"
27 #endif 28 #endif
28 29
29 using storage_monitor::StorageInfo; 30 using storage_monitor::StorageInfo;
30 using storage_monitor::TestStorageMonitor; 31 using storage_monitor::TestStorageMonitor;
31 32
32 namespace { 33 namespace {
33 34
34 std::string GalleryName(const MediaGalleryPrefInfo& gallery) { 35 std::string GalleryName(const MediaGalleryPrefInfo& gallery) {
35 base::string16 name = gallery.GetGalleryDisplayName(); 36 base::string16 name = gallery.GetGalleryDisplayName();
36 return base::UTF16ToASCII(name); 37 return base::UTF16ToASCII(name);
37 } 38 }
38 39
39 class MockMediaGalleriesDialog
40 : public MediaGalleriesDialog {
41 public:
42 typedef base::Callback<void(int update_count)> DialogDestroyedCallback;
43
44 explicit MockMediaGalleriesDialog(const DialogDestroyedCallback& callback)
45 : update_count_(0),
46 dialog_destroyed_callback_(callback) {
47 }
48
49 virtual ~MockMediaGalleriesDialog() {
50 dialog_destroyed_callback_.Run(update_count_);
51 }
52
53 // MockMediaGalleriesDialog implementation.
54 virtual void UpdateGalleries() OVERRIDE {
55 update_count_++;
56 }
57
58 // Number of times UpdateResults has been called.
59 int update_count() {
60 return update_count_;
61 }
62
63 private:
64 int update_count_;
65
66 DialogDestroyedCallback dialog_destroyed_callback_;
67
68 DISALLOW_COPY_AND_ASSIGN(MockMediaGalleriesDialog);
69 };
70
71 } // namespace 40 } // namespace
72 41
73 class MediaGalleriesPermissionControllerTest : public ::testing::Test { 42 class MediaGalleriesPermissionControllerTest : public ::testing::Test {
74 public: 43 public:
75 MediaGalleriesPermissionControllerTest() 44 MediaGalleriesPermissionControllerTest()
76 : dialog_(NULL), 45 : dialog_(NULL),
77 dialog_update_count_at_destruction_(0), 46 dialog_update_count_at_destruction_(0),
78 controller_(NULL), 47 controller_(NULL),
79 profile_(new TestingProfile()), 48 profile_(new TestingProfile()),
80 weak_factory_(this) { 49 weak_factory_(this) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 282
314 gallery.volume_label = base::string16(); 283 gallery.volume_label = base::string16();
315 EXPECT_EQ("vendor, model", GalleryName(gallery)); 284 EXPECT_EQ("vendor, model", GalleryName(gallery));
316 285
317 gallery.total_size_in_bytes = 1000000; 286 gallery.total_size_in_bytes = 1000000;
318 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery)); 287 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery));
319 288
320 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path")); 289 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path"));
321 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery)); 290 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery));
322 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698