Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_search_request.hpp « search_tests_support « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4b86d5a3e2cdb57eeb434ce229cd53c25e5796aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include "geometry/rect2d.hpp"

#include "search/params.hpp"
#include "search/result.hpp"

#include "std/condition_variable.hpp"
#include "std/mutex.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"

#include "base/timer.hpp"

namespace search
{
namespace tests_support
{
class TestSearchEngine;

// This class wraps a search query to a search engine. Note that the
// last token will be handled as a complete token iff it will be
// followed by a space in a query.
class TestSearchRequest
{
public:
  TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale,
                    Mode mode, m2::RectD const & viewport);
  TestSearchRequest(TestSearchEngine & engine, SearchParams params, m2::RectD const & viewport);

  void Wait();

  // Call these functions only after call to Wait().
  steady_clock::duration ResponseTime() const;
  vector<search::Result> const & Results() const;

protected:
  TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale,
                    Mode mode, m2::RectD const & viewport, TOnStarted onStarted,
                    TOnResults onResults);

  void SetUpCallbacks(SearchParams & params);

  void OnStarted();
  void OnResults(search::Results const & results);

  condition_variable m_cv;
  mutable mutex m_mu;

  vector<search::Result> m_results;
  bool m_done = false;

  my::Timer m_timer;
  steady_clock::duration m_startTime;
  steady_clock::duration m_endTime;
};
}  // namespace tests_support
}  // namespace search