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

Side by Side Diff: webkit/blob/deletable_file_reference_unittest.cc

Issue 3455022: Revert 60378 (trying to track down http://crbug.com/56752 )- Flesh out URLLoa... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 | « webkit/blob/deletable_file_reference.cc ('k') | webkit/blob/webkit_blob.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/blob/deletable_file_reference.h"
6
7 #include "base/file_util.h"
8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace webkit_blob {
13
14 TEST(DeletableFileReferenceTest, TestReferences) {
15 scoped_refptr<base::MessageLoopProxy> loop_proxy =
16 base::MessageLoopProxy::CreateForCurrentThread();
17
18 // Create a file.
19 FilePath file;
20 file_util::CreateTemporaryFile(&file);
21 EXPECT_TRUE(file_util::PathExists(file));
22
23 // Create a first reference to that file.
24 scoped_refptr<DeletableFileReference> reference1;
25 reference1 = DeletableFileReference::Get(file);
26 EXPECT_FALSE(reference1.get());
27 reference1 = DeletableFileReference::GetOrCreate(file, loop_proxy);
28 EXPECT_TRUE(reference1.get());
29 EXPECT_TRUE(file == reference1->path());
30
31 // Get a second reference to that file.
32 scoped_refptr<DeletableFileReference> reference2;
33 reference2 = DeletableFileReference::Get(file);
34 EXPECT_EQ(reference1.get(), reference2.get());
35 reference2 = DeletableFileReference::GetOrCreate(file, loop_proxy);
36 EXPECT_EQ(reference1.get(), reference2.get());
37
38 // Drop the first reference, the file and reference should still be there.
39 reference1 = NULL;
40 EXPECT_TRUE(DeletableFileReference::Get(file).get());
41 MessageLoop::current()->RunAllPending();
42 EXPECT_TRUE(file_util::PathExists(file));
43
44 // Drop the second reference, the file and reference should get deleted.
45 reference2 = NULL;
46 EXPECT_FALSE(DeletableFileReference::Get(file).get());
47 MessageLoop::current()->RunAllPending();
48 EXPECT_FALSE(file_util::PathExists(file));
49 }
50
51 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/deletable_file_reference.cc ('k') | webkit/blob/webkit_blob.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698