OLD | NEW |
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 "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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 controller_(NULL), | 47 controller_(NULL), |
48 profile_(new TestingProfile()), | 48 profile_(new TestingProfile()), |
49 weak_factory_(this) { | 49 weak_factory_(this) { |
50 } | 50 } |
51 | 51 |
52 virtual ~MediaGalleriesPermissionControllerTest() { | 52 virtual ~MediaGalleriesPermissionControllerTest() { |
53 EXPECT_FALSE(controller_); | 53 EXPECT_FALSE(controller_); |
54 EXPECT_FALSE(dialog_); | 54 EXPECT_FALSE(dialog_); |
55 } | 55 } |
56 | 56 |
57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
58 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); | 58 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); |
59 | 59 |
60 extensions::TestExtensionSystem* extension_system( | 60 extensions::TestExtensionSystem* extension_system( |
61 static_cast<extensions::TestExtensionSystem*>( | 61 static_cast<extensions::TestExtensionSystem*>( |
62 extensions::ExtensionSystem::Get(profile_.get()))); | 62 extensions::ExtensionSystem::Get(profile_.get()))); |
63 extension_system->CreateExtensionService( | 63 extension_system->CreateExtensionService( |
64 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 64 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
65 | 65 |
66 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 66 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
67 base::RunLoop loop; | 67 base::RunLoop loop; |
68 gallery_prefs_->EnsureInitialized(loop.QuitClosure()); | 68 gallery_prefs_->EnsureInitialized(loop.QuitClosure()); |
69 loop.Run(); | 69 loop.Run(); |
70 | 70 |
71 std::vector<std::string> read_permissions; | 71 std::vector<std::string> read_permissions; |
72 read_permissions.push_back( | 72 read_permissions.push_back( |
73 extensions::MediaGalleriesPermission::kReadPermission); | 73 extensions::MediaGalleriesPermission::kReadPermission); |
74 extension_ = AddMediaGalleriesApp("read", read_permissions, profile_.get()); | 74 extension_ = AddMediaGalleriesApp("read", read_permissions, profile_.get()); |
75 } | 75 } |
76 | 76 |
77 virtual void TearDown() OVERRIDE { | 77 virtual void TearDown() override { |
78 TestStorageMonitor::Destroy(); | 78 TestStorageMonitor::Destroy(); |
79 } | 79 } |
80 | 80 |
81 void StartDialog() { | 81 void StartDialog() { |
82 ASSERT_FALSE(controller_); | 82 ASSERT_FALSE(controller_); |
83 controller_ = new MediaGalleriesPermissionController( | 83 controller_ = new MediaGalleriesPermissionController( |
84 *extension_.get(), | 84 *extension_.get(), |
85 gallery_prefs_.get(), | 85 gallery_prefs_.get(), |
86 base::Bind(&MediaGalleriesPermissionControllerTest::CreateMockDialog, | 86 base::Bind(&MediaGalleriesPermissionControllerTest::CreateMockDialog, |
87 base::Unretained(this)), | 87 base::Unretained(this)), |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 gallery.volume_label = base::string16(); | 299 gallery.volume_label = base::string16(); |
300 EXPECT_EQ("vendor, model", GalleryName(gallery)); | 300 EXPECT_EQ("vendor, model", GalleryName(gallery)); |
301 | 301 |
302 gallery.total_size_in_bytes = 1000000; | 302 gallery.total_size_in_bytes = 1000000; |
303 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery)); | 303 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery)); |
304 | 304 |
305 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path")); | 305 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path")); |
306 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery)); | 306 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery)); |
307 } | 307 } |
OLD | NEW |