-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpotifyAppProfile.cpp
More file actions
106 lines (85 loc) · 3.29 KB
/
SpotifyAppProfile.cpp
File metadata and controls
106 lines (85 loc) · 3.29 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "stdafx.h"
#include "SpotifyAppProfile.h"
#include <stdio.h>
#include <iostream>
using namespace std;
SpotifyAppProfile::SpotifyAppProfile()
{
FriendlyName = "Spotify Music";
Package = "com.spotify.music";
/* Build Interactions */
/*
AppInteraction *action_launch_app;
AppInteraction *action_tap_search;
AppInteraction *action_text_search;
AppInteraction *action_tap_selectTopResult;
AppInteraction *action_tap_shufflePlay;
AppInteraction *action_tap_playPause;
*/
TapAppInteraction *action_tap_search = new TapAppInteraction("Go to Search Menu", "ref_images/spotify_search_icon.png");
AppActions.push_back(action_tap_search);
ActionMap.insert(std::make_pair("goToSearchMenu", action_tap_search));
TapAppInteraction *action_tap_searchBar = new TapAppInteraction("Select Search Bar", "ref_images/spotify_search_bar.png");
ActionMap.insert(std::make_pair("selectSearchBar", action_tap_searchBar));
TapAppInteraction *action_tap_shufflePlay = new TapAppInteraction("Shuffle Play Current Artist/Album", "ref_images/spotify_shuffle_play.png");
ActionMap.insert(std::make_pair("selectShufflePlay", action_tap_shufflePlay));
TextAppInteraction *action_text_searchQuery = new TextAppInteraction();
ActionMap.insert(std::make_pair("inputSearchQuery", action_text_searchQuery));
TapAppInteraction *action_tap_topSearchResult = new TapAppInteraction("Select Top Search Result", 80, 340);
ActionMap.insert(std::make_pair("selectTopSearchResult", action_tap_topSearchResult));
TapAppInteraction *action_tap_play = new TapAppInteraction("Tap Play Button", "ref_images/spotify_play_icon.png");
ActionMap.insert(std::make_pair("playMusic", action_tap_play));
TapAppInteraction *action_tap_pause = new TapAppInteraction("Tap Pause Button", "ref_images/spotify_pause_icon.png");
ActionMap.insert(std::make_pair("pauseMusic", action_tap_pause));
}
SpotifyAppProfile::~SpotifyAppProfile()
{
}
void SpotifyAppProfile::launchApp()
{
std::string runnable_cmd = launchAppCommand();
system(runnable_cmd.c_str());
}
void SpotifyAppProfile::launchSearchMenu()
{
AppInteraction* action = ActionMap["goToSearchMenu"];
action->launchInteraction();
}
void SpotifyAppProfile::selectSearchBar()
{
AppInteraction* action = ActionMap["selectSearchBar"];
action->launchInteraction();
}
void SpotifyAppProfile::runSearchQuery(std::string query_text)
{
launchSearchMenu();
/*selectSearchBar(); bug with the select query */
launchSearchMenu();
TextAppInteraction* action = dynamic_cast<TextAppInteraction*>(ActionMap["inputSearchQuery"]);
action->launchInteraction(query_text);
AppInteraction* next_action = ActionMap["selectTopSearchResult"];
next_action->launchInteraction();
}
void SpotifyAppProfile::shufflePlay()
{
AppInteraction* action = ActionMap["selectShufflePlay"];
action->launchInteraction();
TapAppInteraction* tapAction = dynamic_cast<TapAppInteraction*>(action);
int x = std::get<0>(tapAction->getXY());
int y = std::get<1>(tapAction->getXY());
cout << "x: " << x << " , y: " << y << std::endl;
}
bool SpotifyAppProfile::play()
{
AppInteraction* action = ActionMap["playMusic"];
action->launchInteraction();
return true;
/*TODO: Check current state*/
}
bool SpotifyAppProfile::pause()
{
AppInteraction* action = ActionMap["pauseMusic"];
action->launchInteraction();
return true;
/*TODO: Check current state*/
}