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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc

Issue 9820003: Implementation of beginning of Declarative Web Request API backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion_attribute.h"
6
7 #include "base/message_loop.h"
8 #include "base/values.h"
9 #include "net/url_request/url_request_test_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace {
13 const char kSchemeConditionName[] = "scheme";
14 const char kUnknownConditionName[] = "unknownType";
15 } // namespace
16
17 namespace extensions {
18 namespace declarative_webrequest {
19
20 TEST(WebRequestConditionAttributeFactoryTest, CreateConditionAttribute) {
21 // Necessary for TestURLRequest.
22 MessageLoop message_loop(MessageLoop::TYPE_IO);
23
24 std::string error;
25 scoped_ptr<WebRequestConditionAttribute> result;
26 StringValue http_string_value("http");
27 ListValue list_value;
28
29 // Test wrong condition name passed.
30 error.clear();
31 result = WebRequestConditionAttributeFactory::Create(
32 kUnknownConditionName, &http_string_value, &error);
33 EXPECT_FALSE(error.empty());
34 EXPECT_FALSE(result.get());
35
36 // Test wrong data type passed
37 error.clear();
38 result = WebRequestConditionAttributeFactory::Create(
39 kUnknownConditionName, &list_value, &error);
40 EXPECT_FALSE(error.empty());
41 EXPECT_FALSE(result.get());
42
43 // Test success
44 error.clear();
45 result = WebRequestConditionAttributeFactory::Create(
46 kSchemeConditionName, &http_string_value, &error);
47 EXPECT_TRUE(error.empty());
48 ASSERT_TRUE(result.get());
49 EXPECT_EQ(WebRequestConditionAttribute::CONDITION_HAS_SCHEME, result->type());
50 TestURLRequest url_request_ok(GURL("http://www.example.com"), NULL);
51 EXPECT_TRUE(result->IsFulfilled(&url_request_ok));
52 TestURLRequest url_request_fail(GURL("https://www.example.com"), NULL);
53 EXPECT_FALSE(result->IsFulfilled(&url_request_fail));
54 }
55
56 } // namespace declarative_webrequest
57 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698