Merge "Adding tests and move launcher.proto"
This commit is contained in:
committed by
Android (Google) Code Review
commit
761b0bd7c9
@@ -22,7 +22,6 @@ option java_outer_classname = "AtomsProto";
|
||||
|
||||
import "frameworks/base/cmds/statsd/src/atom_field_options.proto";
|
||||
import "frameworks/base/core/proto/android/app/enums.proto";
|
||||
import "frameworks/base/core/proto/android/app/launcher/launcher.proto";
|
||||
import "frameworks/base/core/proto/android/app/settings_enums.proto";
|
||||
import "frameworks/base/core/proto/android/app/job/enums.proto";
|
||||
import "frameworks/base/core/proto/android/bluetooth/enums.proto";
|
||||
@@ -30,6 +29,7 @@ import "frameworks/base/core/proto/android/os/enums.proto";
|
||||
import "frameworks/base/core/proto/android/server/enums.proto";
|
||||
import "frameworks/base/core/proto/android/service/procstats_enum.proto";
|
||||
import "frameworks/base/core/proto/android/stats/enums.proto";
|
||||
import "frameworks/base/core/proto/android/stats/launcher/launcher.proto";
|
||||
import "frameworks/base/core/proto/android/telecomm/enums.proto";
|
||||
import "frameworks/base/core/proto/android/telephony/enums.proto";
|
||||
import "frameworks/base/core/proto/android/view/enums.proto";
|
||||
@@ -1441,10 +1441,10 @@ message PhoneStateChanged {
|
||||
}
|
||||
|
||||
message LauncherUIChanged {
|
||||
optional android.app.launcher.LauncherAction action = 1;
|
||||
optional android.app.launcher.LauncherState src_state = 2;
|
||||
optional android.app.launcher.LauncherState dst_state = 3;
|
||||
optional android.app.launcher.LauncherExtension extension = 4 [(log_mode) = MODE_BYTES];
|
||||
optional android.stats.launcher.LauncherAction action = 1;
|
||||
optional android.stats.launcher.LauncherState src_state = 2;
|
||||
optional android.stats.launcher.LauncherState dst_state = 3;
|
||||
optional android.stats.launcher.LauncherExtension extension = 4 [(log_mode) = MODE_BYTES];
|
||||
optional bool is_swipe_up_enabled = 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/logd/LogEvent.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <log/log_event_list.h>
|
||||
#include "src/logd/LogEvent.h"
|
||||
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
|
||||
#include "frameworks/base/core/proto/android/stats/launcher/launcher.pb.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
@@ -22,6 +24,9 @@ namespace android {
|
||||
namespace os {
|
||||
namespace statsd {
|
||||
|
||||
using std::string;
|
||||
using util::ProtoOutputStream;
|
||||
|
||||
TEST(LogEventTest, TestLogParsing) {
|
||||
LogEvent event1(1, 2000);
|
||||
|
||||
@@ -390,6 +395,57 @@ TEST(LogEventTest, TestKeyValuePairsEvent) {
|
||||
}
|
||||
|
||||
|
||||
TEST(LogEventTest, TestBinaryFieldAtom) {
|
||||
Atom launcherAtom;
|
||||
auto launcher_event = launcherAtom.mutable_launcher_event();
|
||||
launcher_event->set_action(stats::launcher::LauncherAction::LONGPRESS);
|
||||
launcher_event->set_src_state(stats::launcher::LauncherState::OVERVIEW);
|
||||
launcher_event->set_dst_state(stats::launcher::LauncherState::ALLAPPS);
|
||||
|
||||
auto extension = launcher_event->mutable_extension();
|
||||
|
||||
auto src_target = extension->add_src_target();
|
||||
src_target->set_type(stats::launcher::LauncherTarget_Type_ITEM_TYPE);
|
||||
src_target->set_item(stats::launcher::LauncherTarget_Item_FOLDER_ICON);
|
||||
|
||||
auto dst_target = extension->add_dst_target();
|
||||
dst_target->set_type(stats::launcher::LauncherTarget_Type_ITEM_TYPE);
|
||||
dst_target->set_item(stats::launcher::LauncherTarget_Item_WIDGET);
|
||||
|
||||
string extension_str;
|
||||
extension->SerializeToString(&extension_str);
|
||||
|
||||
LogEvent event1(Atom::kLauncherEventFieldNumber, 1000);
|
||||
|
||||
event1.write((int32_t)stats::launcher::LauncherAction::LONGPRESS);
|
||||
event1.write((int32_t)stats::launcher::LauncherState::OVERVIEW);
|
||||
event1.write((int64_t)stats::launcher::LauncherState::ALLAPPS);
|
||||
event1.write(extension_str);
|
||||
event1.init();
|
||||
|
||||
ProtoOutputStream proto;
|
||||
event1.ToProto(proto);
|
||||
|
||||
std::vector<uint8_t> outData;
|
||||
outData.resize(proto.size());
|
||||
size_t pos = 0;
|
||||
auto iter = proto.data();
|
||||
while (iter.readBuffer() != NULL) {
|
||||
size_t toRead = iter.currentToRead();
|
||||
std::memcpy(&(outData[pos]), iter.readBuffer(), toRead);
|
||||
pos += toRead;
|
||||
iter.rp()->move(toRead);
|
||||
}
|
||||
|
||||
std::string result_str(outData.begin(), outData.end());
|
||||
std::string orig_str;
|
||||
launcherAtom.SerializeToString(&orig_str);
|
||||
|
||||
EXPECT_EQ(orig_str, result_str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace statsd
|
||||
} // namespace os
|
||||
} // namespace android
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
package android.app.launcher;
|
||||
package android.stats.launcher;
|
||||
option java_multiple_files = true;
|
||||
|
||||
enum LauncherAction {
|
||||
Reference in New Issue
Block a user