You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
#ifndef _TR_TEST_SESSION_CONTEXT_HPP_ |
|
#define _TR_TEST_SESSION_CONTEXT_HPP_ |
|
|
|
#include <TorrentContext.hpp> |
|
#include <libtorrent/magnet_uri.hpp> |
|
#include <sstream> |
|
#include <vector> |
|
|
|
class TestSessionSettings { |
|
public: |
|
int download_rate_limit = 1; |
|
int upload_rate_limit = 2; |
|
int listen_interfaces = 3; |
|
int enable_dht = 4; |
|
bool enable_dht_ = true; |
|
int download_rate_limit_ = 0; |
|
int upload_rate_limit_ = 0; |
|
std::string listen_interfaces_ = "0.0.0.0:0"; |
|
void set_bool(int type, int value); |
|
void set_int(int type, int value); |
|
void set_str(int type, std::string value); |
|
int get_int(int type) const; |
|
bool get_bool(int type); |
|
std::string get_str(int type); |
|
}; |
|
|
|
class TestSession { |
|
public: |
|
TestSession() { |
|
invalid_.valid = false; |
|
} |
|
bool valid = false; |
|
bool paused = false; |
|
std::vector<TestTorrent> torrents_; |
|
TestSessionSettings settings_; |
|
bool is_valid(); |
|
TestSessionSettings get_settings(); |
|
bool is_paused() const; |
|
void pause(); |
|
void resume(); |
|
int listen_port(); |
|
bool is_dht_running() const; |
|
std::vector<TestTorrent> &get_torrents(); |
|
TestTorrent &find_torrent(const libtorrent::sha1_hash &hash); |
|
void remove_torrent(const TestTorrent &torrent, int options); |
|
void apply_settings(TestSessionSettings settings); |
|
void async_add_torrent(const libtorrent::add_torrent_params ¶ms); |
|
void post_torrent_updates(int flags = 0); |
|
int post_torrent_updates_calls_ = 0; |
|
void theTorrentExists(); |
|
TestTorrent invalid_; |
|
}; |
|
|
|
|
|
const auto magnet_uri = "magnet:?xt=urn:btih:" + torrent_id + "&dn=Taylor Swift&tr=http://tracker.sout.no"; |
|
|
|
const nlohmann::json session_json = { |
|
{"dht_enabled", true}, |
|
{"down_limit", 0}, |
|
{"paused", false}, |
|
{"port", 0}, |
|
{"torrents", 0}, |
|
{"up_limit", 0}}; |
|
|
|
|
|
#endif |