Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/BaseJsTest.h

Issue 10802049: Functional prefs implementation (Closed)
Patch Set: Cleaned up init.js a bit Created June 5, 2013, 9:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 void operator()(LogLevel logLevel, const std::string& message, 28 void operator()(LogLevel logLevel, const std::string& message,
29 const std::string& source) 29 const std::string& source)
30 { 30 {
31 throw std::runtime_error("Unexpected error: " + message); 31 throw std::runtime_error("Unexpected error: " + message);
32 } 32 }
33 }; 33 };
34 34
35 class ThrowingFileSystem : public AdblockPlus::FileSystem 35 class ThrowingFileSystem : public AdblockPlus::FileSystem
36 { 36 {
37 public:
37 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const 38 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const
38 { 39 {
39 throw std::runtime_error("Not implemented"); 40 throw std::runtime_error("Not implemented");
40 } 41 }
41 42
42 void Write(const std::string& path, 43 void Write(const std::string& path,
43 std::tr1::shared_ptr<std::istream> content) 44 std::tr1::shared_ptr<std::istream> content)
44 { 45 {
45 throw std::runtime_error("Not implemented"); 46 throw std::runtime_error("Not implemented");
46 } 47 }
(...skipping 15 matching lines...) Expand all
62 63
63 std::string Resolve(const std::string& path) const 64 std::string Resolve(const std::string& path) const
64 { 65 {
65 throw std::runtime_error("Not implemented"); 66 throw std::runtime_error("Not implemented");
66 } 67 }
67 68
68 }; 69 };
69 70
70 class ThrowingWebRequest : public AdblockPlus::WebRequest 71 class ThrowingWebRequest : public AdblockPlus::WebRequest
71 { 72 {
73 public:
72 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const 74 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const
73 { 75 {
74 throw std::runtime_error("Unexpected GET: " + url); 76 throw std::runtime_error("Unexpected GET: " + url);
75 } 77 }
76 }; 78 };
77 79
78 class LazyFileSystem : public AdblockPlus::FileSystem 80 class LazyFileSystem : public AdblockPlus::FileSystem
79 { 81 {
82 public:
80 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const 83 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const
81 { 84 {
85 std::string dummyData("");
82 if (path == "patterns.ini") 86 if (path == "patterns.ini")
83 { 87 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~";
84 std::string dummyData("# Adblock Plus preferences\n[Subscription]\nurl=~fl ~"); 88 else if (path == "prefs.json")
85 return std::tr1::shared_ptr<std::istream>(new std::istringstream(dummyData )); 89 dummyData = "{}";
86 } 90 return std::tr1::shared_ptr<std::istream>(new std::istringstream(dummyData)) ;
87 else
88 return std::tr1::shared_ptr<std::istream>();
89 } 91 }
90 92
91 void Write(const std::string& path, 93 void Write(const std::string& path,
92 std::tr1::shared_ptr<std::istream> content) 94 std::tr1::shared_ptr<std::istream> content)
93 { 95 {
94 } 96 }
95 97
96 void Move(const std::string& fromPath, const std::string& toPath) 98 void Move(const std::string& fromPath, const std::string& toPath)
97 { 99 {
98 } 100 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 virtual void SetUp() 146 virtual void SetUp()
145 { 147 {
146 jsEngine = AdblockPlus::JsEngine::New(); 148 jsEngine = AdblockPlus::JsEngine::New();
147 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); 149 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem));
148 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); 150 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem));
149 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); 151 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest));
150 } 152 }
151 }; 153 };
152 154
153 #endif 155 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld