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

Side by Side Diff: ios/chrome/browser/web_resource/web_resource_util_unittest.cc

Issue 2926133002: [ios] Disable WebResourceUtilTest due to risk of timeouts. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/web_resource/web_resource_util.h" 5 #include "ios/chrome/browser/web_resource/web_resource_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 scoped_task_environment_.RunUntilIdle(); 54 scoped_task_environment_.RunUntilIdle();
55 } 55 }
56 56
57 base::test::ScopedTaskEnvironment scoped_task_environment_; 57 base::test::ScopedTaskEnvironment scoped_task_environment_;
58 std::string error_; 58 std::string error_;
59 std::unique_ptr<base::Value> value_; 59 std::unique_ptr<base::Value> value_;
60 bool error_called_; 60 bool error_called_;
61 bool success_called_; 61 bool success_called_;
62 }; 62 };
63 63
64 TEST_F(WebResourceUtilTest, Success) { 64 // TODO(crbug.com/728216): Disabled because
65 // ScopedTaskEnvironment::RunUntilIdle() may hang.
66 TEST_F(WebResourceUtilTest, DISABLED_Success) {
65 const std::string kExpectedKey("foo"); 67 const std::string kExpectedKey("foo");
66 const std::string kExpectedValue("bar"); 68 const std::string kExpectedValue("bar");
67 std::string json = base::StringPrintf("{\"%s\":\"%s\"}", kExpectedKey.c_str(), 69 std::string json = base::StringPrintf("{\"%s\":\"%s\"}", kExpectedKey.c_str(),
68 kExpectedValue.c_str()); 70 kExpectedValue.c_str());
69 GetIOSChromeParseJSONCallback().Run(json, GetSuccessCallback(), 71 GetIOSChromeParseJSONCallback().Run(json, GetSuccessCallback(),
70 GetErrorCallback()); 72 GetErrorCallback());
71 73
72 FlushBackgroundTasks(); 74 FlushBackgroundTasks();
73 75
74 // The success callback is called with the reference value. 76 // The success callback is called with the reference value.
75 EXPECT_FALSE(error_called_); 77 EXPECT_FALSE(error_called_);
76 EXPECT_TRUE(success_called_); 78 EXPECT_TRUE(success_called_);
77 79
78 base::DictionaryValue* dictionary = nullptr; 80 base::DictionaryValue* dictionary = nullptr;
79 ASSERT_TRUE(value_->GetAsDictionary(&dictionary)); 81 ASSERT_TRUE(value_->GetAsDictionary(&dictionary));
80 EXPECT_EQ(1u, dictionary->size()); 82 EXPECT_EQ(1u, dictionary->size());
81 base::Value* actual_value = nullptr; 83 base::Value* actual_value = nullptr;
82 ASSERT_TRUE(dictionary->Get(kExpectedKey, &actual_value)); 84 ASSERT_TRUE(dictionary->Get(kExpectedKey, &actual_value));
83 std::string actual_value_as_string; 85 std::string actual_value_as_string;
84 EXPECT_TRUE(actual_value->GetAsString(&actual_value_as_string)); 86 EXPECT_TRUE(actual_value->GetAsString(&actual_value_as_string));
85 EXPECT_EQ(kExpectedValue, actual_value_as_string); 87 EXPECT_EQ(kExpectedValue, actual_value_as_string);
86 } 88 }
87 89
88 // Only DictionartValues are expected. 90 // Only DictionaryValues are expected.
89 TEST_F(WebResourceUtilTest, UnexpectedValue) { 91 // TODO(crbug.com/728216): Disabled because
92 // ScopedTaskEnvironment::RunUntilIdle() may hang.
93 TEST_F(WebResourceUtilTest, DISABLED_UnexpectedValue) {
90 GetIOSChromeParseJSONCallback().Run("foo", GetSuccessCallback(), 94 GetIOSChromeParseJSONCallback().Run("foo", GetSuccessCallback(),
91 GetErrorCallback()); 95 GetErrorCallback());
92 96
93 FlushBackgroundTasks(); 97 FlushBackgroundTasks();
94 98
95 // The error callback is called. 99 // The error callback is called.
96 EXPECT_TRUE(error_called_); 100 EXPECT_TRUE(error_called_);
97 EXPECT_FALSE(success_called_); 101 EXPECT_FALSE(success_called_);
98 EXPECT_FALSE(error_.empty()); 102 EXPECT_FALSE(error_.empty());
99 } 103 }
100 104
101 // Empty data is not expected. 105 // Empty data is not expected.
102 TEST_F(WebResourceUtilTest, EmptyValue) { 106 // TODO(crbug.com/728216): Disabled because
107 // ScopedTaskEnvironment::RunUntilIdle() may hang.
108 TEST_F(WebResourceUtilTest, DISABLED_EmptyValue) {
103 GetIOSChromeParseJSONCallback().Run(std::string(), GetSuccessCallback(), 109 GetIOSChromeParseJSONCallback().Run(std::string(), GetSuccessCallback(),
104 GetErrorCallback()); 110 GetErrorCallback());
105 111
106 FlushBackgroundTasks(); 112 FlushBackgroundTasks();
107 113
108 // The error callback is called. 114 // The error callback is called.
109 EXPECT_TRUE(error_called_); 115 EXPECT_TRUE(error_called_);
110 EXPECT_FALSE(success_called_); 116 EXPECT_FALSE(success_called_);
111 EXPECT_FALSE(error_.empty()); 117 EXPECT_FALSE(error_.empty());
112 } 118 }
113 119
114 // Wrong syntax. 120 // Wrong syntax.
115 TEST_F(WebResourceUtilTest, SyntaxError) { 121 // TODO(crbug.com/728216): Disabled because
122 // ScopedTaskEnvironment::RunUntilIdle() may hang.
123 TEST_F(WebResourceUtilTest, DISABLED_SyntaxError) {
116 GetIOSChromeParseJSONCallback().Run("%$[", GetSuccessCallback(), 124 GetIOSChromeParseJSONCallback().Run("%$[", GetSuccessCallback(),
117 GetErrorCallback()); 125 GetErrorCallback());
118 126
119 FlushBackgroundTasks(); 127 FlushBackgroundTasks();
120 128
121 // The error callback is called. 129 // The error callback is called.
122 EXPECT_TRUE(error_called_); 130 EXPECT_TRUE(error_called_);
123 EXPECT_FALSE(success_called_); 131 EXPECT_FALSE(success_called_);
124 EXPECT_FALSE(error_.empty()); 132 EXPECT_FALSE(error_.empty());
125 } 133 }
126 134
127 } // namespace web_resource 135 } // namespace web_resource
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698