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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_files_unittest.cc

Issue 10384204: gdata: Fix a bug that caused google drive not to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/gdata/gdata_files.h" 5 #include "chrome/browser/chromeos/gdata/gdata_files.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace gdata { 13 namespace gdata {
13 14
14 TEST(GDataRootDirectoryTest, RemoveTemporaryFilesFromCacheMap) { 15 TEST(GDataRootDirectoryTest, RemoveTemporaryFilesFromCacheMap) {
15 scoped_ptr<GDataRootDirectory> root(new GDataRootDirectory); 16 scoped_ptr<GDataRootDirectory> root(new GDataRootDirectory);
16 GDataRootDirectory::CacheMap cache_map; 17 GDataRootDirectory::CacheMap cache_map;
17 cache_map.insert(std::make_pair( 18 cache_map.insert(std::make_pair(
18 "<resource_id_1>", 19 "<resource_id_1>",
19 new GDataRootDirectory::CacheEntry( 20 new GDataRootDirectory::CacheEntry(
(...skipping 21 matching lines...) Expand all
41 root->SetCacheMap(cache_map); 42 root->SetCacheMap(cache_map);
42 root->RemoveTemporaryFilesFromCacheMap(); 43 root->RemoveTemporaryFilesFromCacheMap();
43 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP. 44 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP.
44 ASSERT_TRUE(root->GetCacheEntry("<resource_id_1>", "") == NULL); 45 ASSERT_TRUE(root->GetCacheEntry("<resource_id_1>", "") == NULL);
45 ASSERT_TRUE(root->GetCacheEntry("<resource_id_2>", "") != NULL); 46 ASSERT_TRUE(root->GetCacheEntry("<resource_id_2>", "") != NULL);
46 ASSERT_TRUE(root->GetCacheEntry("<resource_id_3>", "") != NULL); 47 ASSERT_TRUE(root->GetCacheEntry("<resource_id_3>", "") != NULL);
47 ASSERT_TRUE(root->GetCacheEntry("<resource_id_4>", "") == NULL); 48 ASSERT_TRUE(root->GetCacheEntry("<resource_id_4>", "") == NULL);
48 49
49 } 50 }
50 51
52 TEST(GDataRootDirectoryTest, ParseFromString_DetectBadTitle) {
53 GDataRootDirectoryProto proto;
54
55 std::string serialized_proto;
56 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
57
58 GDataRootDirectory root;
59 // This should fail as the title is empty.
60 // root.title() should be unchanged.
61 ASSERT_FALSE(root.ParseFromString(serialized_proto));
62 ASSERT_EQ("drive", root.title());
63
64 // Setting the title to "gdata".
65 proto.mutable_gdata_directory()->mutable_gdata_entry()->set_title("gdata");
66 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
67
68 // This should fail as the title is not "drive".
69 // root.title() should be unchanged.
70 ASSERT_FALSE(root.ParseFromString(serialized_proto));
71 ASSERT_EQ("drive", root.title());
72
73 // Setting the title to "drive".
74 proto.mutable_gdata_directory()->mutable_gdata_entry()->set_title("drive");
75 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
76
77 // This should succeed as the title is "drive".
78 ASSERT_TRUE(root.ParseFromString(serialized_proto));
79 ASSERT_EQ("drive", root.title());
80 }
81
51 } // namespace gdata 82 } // namespace gdata
OLDNEW
« chrome/browser/chromeos/gdata/gdata_files.cc ('K') | « chrome/browser/chromeos/gdata/gdata_files.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698